Hi, I'm wondering if a "Scope Tracer" or a "General Scope Function" can be easily implemented with existing boost libraries now. One example use case is to log variable or parameter values or any program state when entering or leaving a scope, but it can do more than just logging, it can, for example, lock/unlock mutex, or prepare/teardown test cases, etc. For logging requirement, to give you an idea, the expected log message looks like this: >04/10/09 05:29:12:210257 entering func foo with parameter a=10, b=1.5, d.x=10, d.y=[string], global d=2, filename:test.cpp>04/10/09 05:29:12:210257 entering while() a=10, b=1.5, d.x=10>04/10/09 05:29:12:210257 leaving while() a=9, b=1.5, d.x=9>04/10/09 05:29:12:210257 entering while() a=9, b=1.5, d.x=9>04/10/09 05:29:12:210257 leaving while() a=8, b=1.5, d.x=8>...>04/10/09 05:29:12:210257 entering while() a=2, b=1.5, d.x=2>04/10/09 05:29:12:210257 leaving while() a=1, b=1.5, d.x=1>04/10/09 05:29:12:210257 entering while() a=1, b=1.5, d.x=1>04/10/09 05:29:12:210257 leaving while() a=0, b=1.5, d.x=0>04/10/09 05:29:12:210257 leaving function foo with parameter a=0, b=1.5, d.x=0, d.y=[string], global d=2, filename:test.cpp It does not have to be logging, it can do any general processing when entering/leaving a scope. I implemented a small library to do so in 2008 mainly for tracing, it worked fine for me and I never revisited it again until recently. Wondering if boost has libraries to support such a requirment. My implementation has a template class logger_class which can manage the log-level at runtime and send the log message to standard-output or other places. Application code use a macro to invoke the library, the macro can be disabled at compile time, or weakened to only log scope without variables. Example of the macro definition:
#ifdef ENABLE_ONLY_SCOPE_TRACER
#define SCOPE_TRACER(logger_class, logger, args, level, scope) \
scope_tracer