[Ns-developers] [ns3] logging proposal

Gustavo Carneiro gjcarneiro at gmail.com
Tue Apr 15 14:35:09 PDT 2008


On 15/04/2008, Mathieu Lacage <mathieu.lacage at sophia.inria.fr> wrote:
>
>
> On Tue, 2008-04-15 at 21:49 +0100, Gustavo Carneiro wrote:
>
> >
> > I am fine with your perl script, but I am thinking now that it is not
> > at all clear that NS_LOG_PARAMS also outputs the function name,
> > besides the parameters themselves, so the pairing of NS_LOG_PARAMS
> > with NS_LOG_FUNCTION is an error that is bound to occur again.
> >
> > My proposal would be to get rid of the old NS_LOG_FUNCTION and rename
> > NS_LOG_PARAMS to NS_LOG_FUNCTION.  In this case NS_LOG_FUNCTION
> > becomes a function-style macro, and lines like this:
> >
> >     NS_LOG_FUNCTION;
> >
> > need to become like this:
> >
> >     NS_LOG_FUNCTION ();
> >
> > But now NS_LOG_FUNCTION optionally accepts parameters:
> >
> > NS_LOG_FUNCTION (this << that);
>
>
> That is exactly what I would have done if it worked :/
>
> The syntax NS_LOG_FUNCTION (); does not work if you define
> NS_LOG_FUNCTION as:
>
> #define NS_LOG_FUNCTION(parameters) \
>   ...


NS_LOG_FUNCTION (""); works, although it is very unintuitive... :P

The only option is to use variadic macros or, maybe:
>
> #define NS_LOG_FUNCTION0() \
> ...
>
> and, then:
>
> #define NS_LOG_FUNCTION(parameters) \
>   ...


NS_LOG_FUNCTION0 is too cryptic IMHO.

Do you think NS_LOG_FUNCTION_AND_ARGS is too verbose?  Alternatively, rename
your NS_LOG_FUNCTION0 to NS_LOG_FUNCTION_NOARGS.

Else I'm out of ideas... :-/

But NS_LOG_PARAMETERS outputing function name is bit surprising IMHO, and we
should strive to reduce the amount of surprises.

Regards,

-- 
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert


More information about the Ns-developers mailing list