Boost logo

Boost :

From: Alexander Nasonov (alnsn_at_[hidden])
Date: 2004-11-14 11:51:13

Markus Sch?pflin wrote:
> 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 is fine except that it doesn't look like a valid function call.
IMO, function call style is easier to remember.

> 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.

This is nice for general things but not that nice for call traces.
They are special case of logging with some specific requirements.
Some of them might be:

  - strace/ltrace format
  - function decls
  - Object identities (== dynamic_cast<void*>(this) for poly classes)
    primarily for sequence diagrams

Uniform interface could let you switch between different formats without
rewriting any tracing code.

Alexander Nasonov

Boost list run by bdawes at, gregod at, cpdaniel at, john at