11 #include <RADCore/RADLicenseGate.h>
36 virtual void write(
Level level,
const std::string& category,
const std::string& line) = 0;
71 std::unique_ptr<Impl> pImpl_;
90 std::string category_;
91 std::ostringstream stream_;
95 std::shared_ptr<Sink>
consoleSink(
bool stderrForWarnings =
true);
97 std::shared_ptr<Sink>
fileSink(
const std::string& path);
99 std::shared_ptr<Sink>
rotatingFileSink(
const std::string& path,
size_t maxBytes,
size_t maxFiles = 3);
101 std::shared_ptr<Sink>
syslogSink(std::string ident =
"RADLib");
108 #define RADLOG_TRACE(category) RADLogging::LogStream(RADLogging::Level::Trace, category)
110 #define RADLOG_DEBUG(category) RADLogging::LogStream(RADLogging::Level::Debug, category)
112 #define RADLOG_INFO(category) RADLogging::LogStream(RADLogging::Level::Info, category)
114 #define RADLOG_WARNING(category) RADLogging::LogStream(RADLogging::Level::Warning, category)
116 #define RADLOG_ERROR(category) RADLogging::LogStream(RADLogging::Level::Error, category)
Streaming log record; emits on destruction.
Definition: RADLogging.h:75
LogStream & operator<<(const T &value)
Appends a value.
Definition: RADLogging.h:83
LogStream(Level level, std::string category)
Creates a stream record.
~LogStream()
Emits the accumulated message.
Async process-wide logger.
Definition: RADLogging.h:42
static Logger & instance()
Returns singleton logger.
void setLevel(Level level)
Sets minimum level.
void start()
Starts worker thread.
void flush()
Flushes queued log messages.
void log(Level level, std::string category, std::string message)
Queues one log message.
Level level() const
Returns minimum level.
void shutdown()
Stops worker thread after draining queued messages.
void addSink(std::shared_ptr< Sink > sink)
Adds a sink. Existing sinks are preserved.
bool shouldLog(Level level, const std::string &category) const
Returns true when a message should be accepted.
void clearSinks()
Removes all sinks.
void setCategoryEnabled(const std::string &category, bool enabled)
Enables or disables a category.
Logger sink interface.
Definition: RADLogging.h:32
virtual void write(Level level, const std::string &category, const std::string &line)=0
Writes one already-formatted log line.
virtual void flush()
Flushes buffered output.
Definition: RADLogging.h:38
Definition: RADLogging.h:18
std::shared_ptr< Sink > consoleSink(bool stderrForWarnings=true)
Creates a console sink.
Level
Log severity.
Definition: RADLogging.h:21
std::string levelName(Level level)
Formats a level as text.
std::shared_ptr< Sink > syslogSink(std::string ident="RADLib")
Creates a syslog sink.
std::shared_ptr< Sink > rotatingFileSink(const std::string &path, size_t maxBytes, size_t maxFiles=3)
Creates a rotating file sink.
std::shared_ptr< Sink > fileSink(const std::string &path)
Creates a file sink.