idea request: generic function logging

Discussion in 'C++' started by Noah Roberts, Nov 7, 2006.

  1. Noah Roberts

    Noah Roberts Guest

    I need to create a log file that logs calls to a certain API. The
    obvious way to do this is to put a bunch of output functions
    before/after calls but it seems to me that there should be a generic
    way to do this. Perhaps some way to override or use boost::function so
    that you just wrap up your function in one of these function logging
    objects and then invoke it...it does the rest. That is the kind of
    thing I am looking for.

    Anyone got any great ideas how to do this? The one I have involves
    figuring out how function works and sort of recreating that
    functionality I would need to make this work. I'm lazy enough to want
    to find an easier way.
    Noah Roberts, Nov 7, 2006
    #1
    1. Advertising

  2. Noah Roberts

    JoShCrUz Guest

    This is a very good case for using aspects :) shame C++ doesn't support
    them by default ... if you could use a variant (like AspectC++ - see:
    http://en.wikipedia.org/wiki/AspectC , main link is:
    http://www.aspectc.org/) you could potentially log pre-call and
    post-call of all the functions you need.

    As simple as creating an aspect using:

    advice pointcut : before(...) {...}
    the advice code is executed before the join points in the pointcut
    advice pointcut : after(...) {...}
    the advice code is executed after the join points in the pointcut
    JoShCrUz, Nov 7, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Murat Tasan
    Replies:
    1
    Views:
    8,020
    Chaitanya
    Feb 3, 2009
  2. Replies:
    2
    Views:
    417
  3. Replies:
    10
    Views:
    1,217
    Big K
    Feb 2, 2005
  4. Dr Mephesto

    App idea, Any idea on implementation?

    Dr Mephesto, Feb 4, 2008, in forum: Python
    Replies:
    3
    Views:
    701
    Dennis Lee Bieber
    Feb 5, 2008
  5. Replies:
    0
    Views:
    619
Loading...

Share This Page