Log: Filter expression in file stream init

Hello,
I have this piece of code: http://pastebin.com/iMyyaB6a
It adds a file and a console log and reads in a file config:
[Core]
# Filter="%Severity% > 1"
[Sinks.MyConsoleSink1]
Destination=Console
and prints some messages:
using namespace boost::log::trivial;
boost::log::sources::severity_logger

Florian Lindner wrote:
Hello,
I have this piece of code: http://pastebin.com/iMyyaB6a
It adds a file and a console log and reads in a file config:
[Core] # Filter="%Severity% > 1"
[Sinks.MyConsoleSink1] Destination=Console
and prints some messages:
using namespace boost::log::trivial; boost::log::sources::severity_logger
lg; BOOST_LOG_SEV(lg, trace) << "A trace severity message"; BOOST_LOG_SEV(lg, debug) << "A debug severity message"; BOOST_LOG_SEV(lg, info) << "An informational severity message"; BOOST_LOG_SEV(lg, warning) << "A warning severity message"; BOOST_LOG_SEV(lg, error) << "An error severity message"; BOOST_LOG_SEV(lg, fatal) << "A fatal severity message"; It does exactly what I want, prints each message twice to the console. But when I uncomment the Filter expression it prints nothing.
Why not? Severity > 1 means everything info and above, doesn't it?
Ok, it seems in order to use Severity you got to register it before adding
the sinks:
boost::log::register_simple_formatter_factory

Another add: BOOST_LOG_ATTRIBUTE_KEYWORD(severity, "Severity", boost::log::trivial::severity_level) Seems to have no effect at all... ??? Florian Florian Lindner wrote:
Florian Lindner wrote:
Hello,
I have this piece of code: http://pastebin.com/iMyyaB6a
It adds a file and a console log and reads in a file config:
[Core] # Filter="%Severity% > 1"
[Sinks.MyConsoleSink1] Destination=Console
and prints some messages:
using namespace boost::log::trivial; boost::log::sources::severity_logger
lg; BOOST_LOG_SEV(lg, trace) << "A trace severity message"; BOOST_LOG_SEV(lg, debug) << "A debug severity message"; BOOST_LOG_SEV(lg, info) << "An informational severity message"; BOOST_LOG_SEV(lg, warning) << "A warning severity message"; BOOST_LOG_SEV(lg, error) << "An error severity message"; BOOST_LOG_SEV(lg, fatal) << "A fatal severity message"; It does exactly what I want, prints each message twice to the console. But when I uncomment the Filter expression it prints nothing.
Why not? Severity > 1 means everything info and above, doesn't it?
Ok, it seems in order to use Severity you got to register it before adding the sinks:
boost::log::register_simple_formatter_factory char>("Severity"); boost::log::register_simple_filter_factory char>("Severity"); I thought that using the severity_logger is doing that for me. There is a
bug report related to this https://svn.boost.org/trac/boost/ticket/8840,
but it was closed for 1.54 and I am on 1.58. Curious,
Florian
participants (1)
-
Florian Lindner