I would say you cannot. The logging system is layered in three layers (see Design overview of the logging system).
Your severity_logger
is a source logger with attribute severity_level
within the data collection layer.
The severity you set with logging::core::get()->set_filter(...)
is a function object, that set for the logging core. All messages passed to a logger will get filtered by that function object, before being passed to the sinks.
So, there is actually no such thing as severity
is the severity_logger
. The severity is just passed to the core and then to the sinks.
EDIT: Elaborating on my comment, you could also declare a variable severityLevel
and pass it to the set_filter
function (using boost's reference wrapper boost::ref()
)
// defined somewhere:
logging::trivial::severity_level severityLevel = logging::trivial::info;
// passed to set_filter() by reference
logging::core::get()->set_filter(
logging::trivial::severity >= boost::ref(severityLevel));
// try out the logging:
BOOST_LOG_SEV(logger, warning) << "A warning severity message"; // not filtered out
severityLevel = logging::trivial::error;
BOOST_LOG_SEV(logger, warning) << "Another warning message"; // filtered out
set_filter()
in my wrapper class – Votary