the disadvantage is that you limit yourself to a max of 4 different parameters.
In my opinion, a set of embracing macros such as
TRACE << "all of tracing done here via operator<<" << TRACE_END
would be much better.
I use that in all of my code.
something like this:
Code:
#define TRACE_BASE(pp_tracer, pp_traceMode) \
try \
{ \
if(pp_tracer.isTracing(pp_traceMode)) \
{ \
Tracer& xx_tracer = pp_tracer; \
TraceMode xx_traceMode = pp_traceMode; \
std::ostringstream xx_os_yy_1234;
#define TRACE_END \
std::endl; \
xx_tracer.trace( __FILE__, __LINE__, xx_traceMode, xx_os_yy_1234 ); \
} \
} \
catch(...) {}
I must admit that I don't have a snippet ready to demonstrate the use of these macros, but they may give a notion of what is done ...
What I really hate is a set of macros that limits the user to a certain (arbitrary) value of trace "parameters".