Boost logo

Boost Users :

Subject: Re: [Boost-users] [log] Retrieving the current trivial severity level
From: Colin Powers (Colin.Powers_at_[hidden])
Date: 2013-08-20 12:47:17


-----Original Message-----
From: Chris Stylianou [mailto:chris5287_at_[hidden]]
Sent: 20 August 2013 12:55
To: boost-users_at_[hidden]
Subject: [Boost-users] [log] Retrieving the current trivial severity level

Is there any method of retrieve the current severity level from a
"boost::log::sources::severity_logger_mt<boost::log::trivial::severity_level>"
logger.

I would like to store the current severity level in a temporary variable,
upgrade it to a new level using "BOOST_LOG_SEV(logger::get(),
boost::log::trivial::trace)" to write a trace-type message, and then
downgrade the logger back to the previous setting by recalling
"BOOST_LOG_SEV(logger::get(), temporaryVariable)"

--
View this message in context: http://boost.2283326.n4.nabble.com/log-Retrieving-the-current-trivial-severity-level-tp4650901.html
Sent from the Boost - Users mailing list archive at Nabble.com.
I do not think loggers are "set to" any particular log level at any one time. I believe every time you log you must supply a log level, unless I have missed something. Or do you mean filtering?
Perhaps you could have a global variable g_LogLevel. e.g.:
boost::log::trivial::severity_level g_LogLevel = boost::log::trivial::info;
...
BOOST_LOG_SEV(logger::get(), g_LogLevel); //Log at the current level
BOOST_LOG_SEV(logger::get(), boost::log::trivial::trace); //Log at a specific level
When you want to change log levels totally, just change g_LogLevel. Store the value in a temporary variable first if you want to reset it later.
Regards
Colin

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