MeVisLab Toolbox Reference
SeverityChannelLogging

Introduction

This library provides convenient access to the highly configurable and complex logging framework Boost.Log. It offers preconfigured severity levels, logging macros and thread safe logger classes.

Synopsis:

// This is needed to initialize the library and should be called as early as possible
// Choose a logging sinks where records are written to
// any std::ostream implementation is suitable
auto cout_sink = scl::add_console_log(std::cout);
auto cerr_sink = scl::add_console_log(std::cerr);
// Configure how a log record should look like in a given sink
auto formatter = scl::parse_formatter("[%TimeStamp%] [%Severity%] [%ProcessID% %ThreadID%] [%Channel%]: %Message%"));
cout_sink->set_formatter(formatter);
cerr_sink->set_formatter(formatter);
// Decide which levels of severity should go where
cout_sink->set_filter(scl::severity >= scl::Info && scl::severity < scl::Warning);
cerr_sink->set_filter(scl::severity >= scl::Warning && scl::severity <= scl::Critical);
// Create logger instances anywhere you like
scl::Logger logger{ scl::keywords::channel = "MyChannel" };
scl::ThreadSafeLogger ts_logger{ scl::keywords::channel = "OtherChannel" };
// Use the loggers to log information
LOG_DEBUG(logger) << "Some debug message";
LOG_INFO(logger) << "Some information";
LOG_WARNING(logger) << "Some warning";
LOG_ERROR(logger) << "Some error";
LOG_CRITICAL(logger) << "Something bad happened";
// There is also a way to automatically log on scope entry and exit
{
scl::ScopedLog<scl::Logger, scl::Info> scoped_log(logger, "entry information", "exit_information");
// ...
} // scoped_log logs exit information on destruction
#define LOG_WARNING(logger)
#define LOG_ERROR(logger)
#define LOG_DEBUG(logger)
#define LOG_INFO(logger)
#define LOG_CRITICAL(logger)
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
SEVERITYCHANNELLOGGING_EXPORT void initialize()
boost::log::sources::severity_channel_logger_mt< SeverityLevel > ThreadSafeLogger
boost::log::sources::severity_channel_logger< SeverityLevel > Logger