Re: [Cppcms-users] booster::log
Brought to you by:
artyom-beilis
From: Artyom B. <art...@ya...> - 2012-03-15 12:44:41
|
> I don't get it. > If I write something like this: > > using namespace booster::log; > booster::shared_ptr<sinks::file> fsink(new sinks::file()); > fsink->open("server.log"); > fsink->max_files(2); > booster::shared_ptr<sinks::standard_error> csink(new > sinks::standard_error()); > > logger::instance().add_sink(fsink); > logger::instance().add_sink(csink); > > because I want to different log levels, which one is which? :D so how do > I edit the level of fsink and csink separate? Which module should i > declare? Wouldn't it be easier to hand a pointer to the method?! > The question to log or not to log decided on the logger level and not on the sink level. For example: BOOSTER_DEBUG("foo") << "This " << foo.heavy_value(); In normal (non-debug) mode the "foo.heavy_value()" would not be evaluated. Note, you can set logging level per module such that "foo" module would be logged for everything (debug) and "bar" module would be logged only for errors. The sinks are just allow to write to different locations, for example to both syslog and file or something like that. Of course you can do (if you want to) some filtering on sink level as well, but it is not its purpose. Just override the log(message const &) member function of a sink. Artyom Beilis |