RADLib
RADical C++ application framework

RADLogging is the beta logging layer for deployed RADLib applications. It provides an async, process-wide logger with severity levels, category filters, and pluggable sinks.

The core is the singleton RADLogging::Logger, obtained through Logger::instance(). Call start() to launch the background worker thread and shutdown() to drain and stop it; flush() forces queued messages out. setLevel() / level() control the minimum RADLogging::Level (from Trace through Critical, plus Off), and setCategoryEnabled() toggles individual categories. shouldLog() reports whether a level/category pair would be accepted, and log() queues a message directly.

Output destinations are RADLogging::Sink implementations, added with addSink() and removed with clearSinks(). The factory functions consoleSink(), fileSink(), rotatingFileSink() (with maxBytes and maxFiles), and syslogSink() cover the common cases. levelName() formats a level as text.

Most application code uses the streaming macros RADLOG_TRACE, RADLOG_DEBUG, RADLOG_INFO, RADLOG_WARNING, and RADLOG_ERROR. Each takes a category string and returns a RADLogging::LogStream that accumulates via operator<< and emits the completed line when it is destroyed.

Core features:

  • Async process-wide logger.
  • Severity levels and category filters.
  • Console, file, rotating file, and syslog sinks.
  • Streaming macros such as RADLOG_INFO("category") << "message".

Example:

logger.addSink(RADLogging::consoleSink());
logger.addSink(RADLogging::rotatingFileSink("app.log", 1024 * 1024, 3));
logger.setLevel(RADLogging::Level::Info);
logger.setCategoryEnabled("net", false);
logger.start();
RADLOG_INFO("boot") << "RADLib application starting";
RADLOG_WARNING("power") << "battery low: " << 12 << "%";
logger.shutdown();
#define RADLOG_INFO(category)
Logs with RADLogging at info level.
Definition: RADLogging.h:112
#define RADLOG_WARNING(category)
Logs with RADLogging at warning level.
Definition: RADLogging.h:114
static Logger & instance()
Returns singleton logger.
std::shared_ptr< Sink > consoleSink(bool stderrForWarnings=true)
Creates a console sink.
std::shared_ptr< Sink > rotatingFileSink(const std::string &path, size_t maxBytes, size_t maxFiles=3)
Creates a rotating file sink.