From: Markus Schöpflin (markus.schoepflin_at_[hidden])
Date: 2004-11-14 04:42:09


Alexander Nasonov wrote:

> I have a couple of ideas about making function traces nicer:
>
> 1. Use of PP_SEQ interface to "parse" function name and arguments
>
> int X::foo(char* buf, size_t len)
> {
> BOOST_TRACE_MEM_FUN( (foo)(buf, len) );
> // ...
> }
>

[snip]

I have been using some helper macros for tracing which use the boost PP
library.

Basically it looks liket this:

int X::foo(char* buf, size_t len)
{
     some_log_object << STREAM_VARS_SEQ((buf)(len));
}

This expands to

   "buf=" << buf << ",len=" << len

What I like most is that you can specify expressions during tracing like
this: STREAM_VARS_SEQ((buf[0])(2*len)) which of course gets you

   "buf[0]=" << buf[0] << ",2*len" << 2*len

While usage is not really restricted to tracing, that where it gets used
currently.

Markus