From: Vladimir Prus (ghost_at_[hidden])
Date: 2004-03-22 05:36:38
Geoff Leyland wrote:
> > log<error>() << "some error";
> > log<activity>() << "some activity";
> I tend to work with the idea that either I want no logging at all, with
> no code generated, or that logging is built in and I'm prepared to take
> quite a hit for its overhead. I like using strings for keys because
> I'm too disorganised to get all the enums I need in one place in a
> large project.
> However I think in a lot of cases, string keys would be to heavy for
> the run-time decision "log or not", which needs to be quick, even if
> you're generating the (large) stream code.
> void large_function(void)
> unsigned activity_log(get_log_index("my_activity"));
> log(activity_index) << "blah";
You can also use something like:
Logger& l = get_logger("boost::new_interesting_library::error);
l << "blah";
In other words:
1. It's possible to have one object for each log category, must like libcwd
does. You don't have to index logger with category at all and there's no
overhead at all.
2. At the same time you can get logger for specific program part and category
using string key -- must like in Log4j and the clones.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk