Boost logo

Boost :

Subject: Re: [boost] [log] Comments
From: Vladimir Prus (ghost_at_[hidden])
Date: 2010-03-15 15:38:58


On Monday 15 March 2010 21:36:17 Stewart, Robert wrote:

> Vladimir Prus wrote:
> > On Monday 15 March 2010 20:24:49 Andrey Semashev wrote:
> > > On 03/15/2010 01:45 PM, Vladimir Prus wrote:
> > > >
> > > > Also, it prints the thread "number",
> > > > on my system a hex string. I am not sure thread id should
> > > > be part of trivial logging.
> > >
> > > Why not? Why can't a multithreaded application use trivial logging?
> >
> > Because hex string, in a log, is completely useless. It is of
> > any use if you
> > are attached to a still-running application, and can actually
> > figure what a thread id means in your program.
>
> I disagree. The distinct thread IDs allow one to distill the output contributed by different threads.
> One can filter the output to see only that for a particular thread, for example.
> The output logged will indicate the thread, if the threads are created for different tasks.
> If the threads are simply divvying up parallelizable work, then the separate IDs are still useful
> to understand how much work was done by each thread and, perhaps, how the work was divided.

Ok, then thread ids have some uses. Still, it's probably more like advanced usage than
trivial logging. Further, note that on Linux, Boost is always built with threading=multi
(and Boost.Log does not even build with threading=single), so you'll get thread id
even for applications that do not, in fact, create any threads.

It seems that some configurability for trivial logging is needed -- which is recurring
conclusion.

BTW, it's not even clear to me how such configurability can be done. Ideally, I want to
do something like:

        get_trivial_logging_sink()->filter_out_attribute("ThreadID");

as opposed to

        get_trivial_logging_sink()->locked_backend()->set_formatter(
        formatters::stream
            << formatters::attr< unsigned int >(traits_t::line_id_attr_name())
            << " [" << formatters::date_time< posix_time::ptime >(traits_t::time_stamp_attr_name())
            << "] [" << formatters::attr< severity_level >(sources::aux::severity_attribute_name< char >::get())
            << "] " << formatters::message< char >();

as the latter would be essentially a copy-paste.

- Volodya


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk