Move global loggers to the global namespace

Avoiding namespace scope globals as initialization order is less well
defined.
This commit is contained in:
Bill Somerville 2020-10-01 23:32:33 +01:00
parent 573b7ea1c8
commit d7eac1803d
No known key found for this signature in database
GPG Key ID: D864B06D1E81618F
4 changed files with 26 additions and 26 deletions

View File

@ -31,15 +31,15 @@ namespace expr = logging::expressions;
namespace attrs = logging::attributes;
namespace ptime = boost::posix_time;
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys,
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = "SYSLOG"));
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data,
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = "DATALOG"));
namespace Logger
{
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (sys,
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = "SYSLOG"));
BOOST_LOG_GLOBAL_LOGGER_CTOR_ARGS (data,
srcs::severity_channel_logger_mt<logging::trivial::severity_level>,
(keywords::channel = "DATALOG"));
namespace
{
// Custom formatter factory to add TimeStamp format support in config ini file.

View File

@ -10,13 +10,13 @@
#include <iosfwd>
#include <string>
BOOST_LOG_GLOBAL_LOGGER (sys,
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
BOOST_LOG_GLOBAL_LOGGER (data,
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
namespace Logger
{
BOOST_LOG_GLOBAL_LOGGER (sys,
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
BOOST_LOG_GLOBAL_LOGGER (data,
boost::log::sources::severity_channel_logger_mt<boost::log::trivial::severity_level>);
// trivial logging to console
void init ();
@ -39,20 +39,20 @@ namespace Logger
/// System Log macros.
/// TRACE < DEBUG < INFO < WARN < ERROR < FATAL
#define LOG_TRACE(ARG) LOG_LOG_LOCATION (Logger::sys::get(), trace, ARG);
#define LOG_DEBUG(ARG) LOG_LOG_LOCATION (Logger::sys::get(), debug, ARG);
#define LOG_INFO(ARG) LOG_LOG_LOCATION (Logger::sys::get(), info, ARG);
#define LOG_WARN(ARG) LOG_LOG_LOCATION (Logger::sys::get(), warning, ARG);
#define LOG_ERROR(ARG) LOG_LOG_LOCATION (Logger::sys::get(), error, ARG);
#define LOG_FATAL(ARG) LOG_LOG_LOCATION (Logger::sys::get(), fatal, ARG);
#define LOG_TRACE(ARG) LOG_LOG_LOCATION (sys::get(), trace, ARG);
#define LOG_DEBUG(ARG) LOG_LOG_LOCATION (sys::get(), debug, ARG);
#define LOG_INFO(ARG) LOG_LOG_LOCATION (sys::get(), info, ARG);
#define LOG_WARN(ARG) LOG_LOG_LOCATION (sys::get(), warning, ARG);
#define LOG_ERROR(ARG) LOG_LOG_LOCATION (sys::get(), error, ARG);
#define LOG_FATAL(ARG) LOG_LOG_LOCATION (sys::get(), fatal, ARG);
/// Data Log macros. Does not include LINE, FILE, FUNCTION.
/// TRACE < DEBUG < INFO < WARN < ERROR < FATAL
#define LOG_DATA_TRACE(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::trace) << ARG
#define LOG_DATA_DEBUG(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::debug) << ARG
#define LOG_DATA_INFO(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::info) << ARG
#define LOG_DATA_WARN(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::warning) << ARG
#define LOG_DATA_ERROR(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::error) << ARG
#define LOG_DATA_FATAL(ARG) BOOST_LOG_SEV (Logger::data::get(), boost::log::trivial::fatal) << ARG
#define LOG_DATA_TRACE(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::trace) << ARG
#define LOG_DATA_DEBUG(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::debug) << ARG
#define LOG_DATA_INFO(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::info) << ARG
#define LOG_DATA_WARN(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::warning) << ARG
#define LOG_DATA_ERROR(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::error) << ARG
#define LOG_DATA_FATAL(ARG) BOOST_LOG_SEV (data::get(), boost::log::trivial::fatal) << ARG
#endif

View File

@ -200,7 +200,7 @@ void WSJTXLogging::qt_log_handler (QtMsgType type, QMessageLogContext const& con
}
// Map non-default Qt categories to logger channels, Qt logger
// context is mapped to the appropriate logger attributes.
auto log = Logger::sys::get ();
auto log = sys::get ();
std::string file;
std::string function;
if (context.file)

View File

@ -317,7 +317,7 @@ int main(int argc, char *argv[])
do
{
// dump settings
auto sys_lg = Logger::sys::get ();
auto sys_lg = sys::get ();
if (auto rec = sys_lg.open_record
(
boost::log::keywords::severity = boost::log::trivial::trace)