ReXGlue SDK
Loading...
Searching...
No Matches
rex::Logger Class Referencefinal

#include <rex/logging/logger.h>

Inheritance diagram for rex::Logger:
[legend]

Public Member Functions

 REX_SETTING (std::string, level, "info", "Lowest level written by a category without its own level", Allowed("trace", "dev", "debug", "info", "warn", "error", "critical", "off"))
 REX_SETTING (std::string, flush_level, "warn", "Lowest level that flushes every sink at once", Allowed("trace", "dev", "debug", "info", "warn", "error", "critical", "off"), kStartupOnly)
 REX_SETTING (i32, flush_interval, 1, "Seconds between flushes", Range{0, 60}, kStartupOnly)
 REX_SETTING (bool, console, true, "Write to the console", kStartupOnly)
 REX_SETTING (bool, debugger, true, "Write to an attached debugger", kStartupOnly)
 REX_SETTING (bool, file, true, "Write a log file under app.log_root", kStartupOnly)
 REX_SETTING (std::string, file_name, "", "File name, the app name when empty", kStartupOnly)
 REX_SETTING (i64, folder_budget, 0, "Bytes of old log files kept, 0 keeps all", Range{0, 9007199254740992.0}, kStartupOnly)
 REX_SETTING (std::string, pattern, "%^%Y-%m-%d %H:%M:%S.%e %Q %-10n %j %v%$", "Layout of each line, an spdlog pattern with %Q for the level letter and %j for the " "thread", kStartupOnly)
 REX_SETTING (bool, color, false, "Color the console", kStartupOnly)
Result< void > AddCategories (std::span< const log::LogCategory *const > categories) override
void RemoveCategories (std::span< const log::LogCategory *const > categories) override
ScopeGuard AddSink (log::ILogSink &sink) override
void Flush () override
void Emit (const log::Message &message) override
Public Member Functions inherited from rex::SettingOwner
 SettingOwner (std::string_view scope)
virtual ~SettingOwner ()
const std::string & GetScope () const
std::span< SettingBase *const > GetOwnedSettings () const

Friends

class ProcessLoggerControl
Logger & GetLogger ()

Additional Inherited Members

Protected Member Functions inherited from rex::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete

Detailed Description

The process logger. Starts on first use and writes to the console and the debugger. Keeps lines until the log file opens, then writes them to it, and keeps the last 4096 for sinks added later. The app opens the file once app.log_root resolves.

Member Function Documentation

◆ AddCategories()

Result< void > rex::Logger::AddCategories ( std::span< const log::LogCategory *const > categories)
nodiscardoverridevirtual

Adds categories, each with a setting log.categories.<name>, empty to follow log.level.

Parameters
categoriesThe categories, which must outlive their removal.
Returns
Ok, or an error when a name is already added by another table.

Implements rex::ILogger.

◆ AddSink()

ScopeGuard rex::Logger::AddSink ( log::ILogSink & sink)
nodiscardoverridevirtual

Adds a sink. It receives the kept lines, then every new line.

Parameters
sinkThe sink, which must outlive the returned guard.
Returns
Guard that removes the sink and waits for a write in progress. Does nothing for a sink that was added twice.

Implements rex::ILogger.

◆ Emit()

void rex::Logger::Emit ( const log::Message & message)
overridevirtual

Writes a message to every sink.

Parameters
messageThe message, valid for the call.

Implements rex::ILogger.

◆ Flush()

void rex::Logger::Flush ( )
overridevirtual

Flushes every sink. Safe from a crash handler.

Implements rex::ILogger.

◆ RemoveCategories()

void rex::Logger::RemoveCategories ( std::span< const log::LogCategory *const > categories)
overridevirtual

Removes categories and their settings. Later lines follow log.level.

Implements rex::ILogger.

◆ GetLogger

Logger & GetLogger ( )
friend

Returns the process logger, starting it on the first call.


The documentation for this class was generated from the following file: