
AMDG Vladimir Prus wrote:
On Monday 15 March 2010 22:07:57 Roland Bock wrote:
After some preparation in the init function, developers can do the following:
src::severity_channel_logger<severity_level> lg1(keywords::channel = "FirstComponent");
BOOST_LOG_SEV(lg1, trace) << "A trace severity message"; BOOST_LOG_SEV(lg1, debug) << "A debug severity message";
I plan to hide most of the first line in a typedef and a convenience function.
What I don't like about this solution is that it requires that you define a new object for every componen, which can be inconvenient, including for header-only libraries. What I would like to have is something like
// myproject.hpp #ifndef COMPONENT #define COMPONENT "unspecified" #endif
#define DEBUG BOOST_LOG_XXX(mygloballogger, COMPONENT, debug)
I guess that what I'd like is a way to specify arbitrary attributes when logging, so BOOST_LOG_XXX would be defined like #define BOOST_LOG_XXX(lg, component, severity) BOOST_LOG_WITH_ATTRS(lg, ("Severity", severity)("Channel", component)) In Christ, Steven Watanabe