|
Boost : |
From: Boris (boriss_at_[hidden])
Date: 2008-08-19 19:41:08
I've been converting a program from John's logging library to Andrey's
logging library. I have to continue playing around with Andrey's library
but in the moment I prefer it over John's library. I can't say really that
this or that is better - it's more the overall handling of Andrey's
logging library which feels more natural for me. Maybe it's also Andrey's
documentation which is rather good (the definitions and design overview
really help to understand the big picture before you dive into all the
details).
I've some questions though for Andrey:
* Where is the connection between a source and a sink? In the basic_usage
example there are two sinks registered (console and file). There is then
one source created which is used to log a message. The message is then
sent to both the console and the file. But what if I want to use for
example two sources and want messages from each source to be sent to a
different sink? Do I understand correctly that I need to use attributes
somehow and filter records based on attribute values? I guess I would need
to add an attribute to each source and set a filter in each sink to make
sure only messages with a certain attribute are written?
* If I want to format a message and add a timestamp why do I need to write
boost::log::formatters::date_time("TimeStamp") and can't write
boost::log::formatters::attr("TimeStamp")? Doesn't the attribute value
know how to be serialized (or isn't it written to a std::ostream)? If I
use boost::log::formatters::attr("TimeStamp") nothing is written to the
log file. It's not a problem to use
boost::log::formatters::date_time("TimeStamp") of course. But I still
wonder why the library can't figure out to write the timestamp if I use
boost::log::formatters::attr("TimeStamp").
* I've been reading
http://boost-log.sourceforge.net/libs/log/doc/html/advanced/advanced.html#advanced.advanced.sources.global_storage
a few times but still don't understand why I can't (or shouldn't)
instantiate a global logger with "boost::log::sources::logger logger;". I
actually did this and everything works (or at least seems to work :). Must
the macro BOOST_LOG_DECLARE_GLOBAL_LOGGER really be used when a global
logger is created? Maybe I better understand if I ask differently: What is
so special about a logger that I need to use a macro to define it globally
while I can create for example a global std::string instance without a
macro?
* By default there is a newline appended to every message written?
By the way, looking at the TODO list: I would be very much interested in
Windows NT event log support. I'm sure it would also convince more
developers to use a logging library as writing texts to files in some
fancy ways can also be done without a logging library. :)
Boris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk