Boost logo

Boost Users :

Subject: [Boost-users] Boost.Log: Set formatter for named_scope attr.
From: David Puffer (David.Puffer_at_[hidden])
Date: 2013-09-30 08:01:29


Hi,

Being new to Boost.Log (and Boost in general) I have spent the last few
days trying to implement Boost.Log - which
Is working fairly well by now.
However - I encountered one problem that I've not been able to solve by
now, although it seems to me quite trivial:

I have successfully registered the "named_scope" attribute and I am
populating its value by a call to BOOST_LOG_FUNCTION.
This works well and I can see the function-name in my log-output.
However - I also want the line-number and the file-name, and discovered
that there's a possibility to set the output-format of the
"named_scope" attribute (which already incorporates file-name and
line-number info) like so:

#include <boost/log/expressions/formatters/named_scope.hpp>

sink->set_formatter(expr::stream << expr::format_named_scope("Scopes",
"%n"));

As documented here:

http://www.boost.org/doc/libs/1_54_0/libs/log/doc/html/log/detailed/expressions.html#log.detailed.expressions.formatters.named_scope

I just don't seem to find any way to get to my sink - which is configured
in a settings-file and evaluated by a call to the init_from_stream()
function.

Is there any way to query for all the sinks - or get a sink by name? How
is one supposed to set a sink formatter for a sink which was generated by
the library
and not the user?
Or is there a way to specify the output-format for named attributes via a
settings-file as well? As far as I can see it's only possible to format
the output of a log record as a
whole - but not single attributes.

Also: Is it correct, that the above function will only set the format for
the "Scopes" attribute - which means I could call this function repeatedly
for lets say the "TimeStamp" attribute
as well?

Best regards,

David



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net