Mila 0.13.48
Deep Neural Network Library
Loading...
Searching...
No Matches
Mila::Logging::Logger Class Referenceabstractexport

Abstract logging interface and static facade. More...

Inheritance diagram for Mila::Logging::Logger:
Collaboration diagram for Mila::Logging::Logger:

Public Member Functions

 Logger (const Logger &)=delete
 Logger (Logger &&)=delete
virtual ~Logger ()=default
virtual LogLevel getLevel () const =0
 Returns the current minimum log level.
virtual bool isEnabled (LogLevel level) const =0
 Returns true if records at level would be emitted.
virtual void log (std::string_view message, LogLevel level, const std::source_location &location=std::source_location::current())=0
 Emits a record at an explicitly specified level.
virtual void log_critical (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Critical level.
virtual void log_debug (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Debug level.
virtual void log_error (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Error level.
virtual void log_info (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Info level.
virtual void log_trace (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Trace level.
virtual void log_warning (std::string_view message, const std::source_location &location=std::source_location::current())=0
 Emits a record at Warning level.
Loggeroperator= (const Logger &)=delete
Loggeroperator= (Logger &&)=delete
virtual void setLevel (LogLevel level)=0
 Sets the minimum level at which records are emitted.

Static Public Member Functions

static void critical (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Critical level via the default logger.
static void debug (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Debug level via the default logger.
static LoggerdefaultLogger ()
 Returns a reference to the registered default logger.
static void error (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Error level via the default logger.
static void info (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Info level via the default logger.
static void setDefaultLogger (Logger *logger)
 Registers a sink as the process-wide default logger.
static void trace (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Trace level via the default logger.
static void warning (std::string_view message, const std::source_location &location=std::source_location::current())
 Emits a record at Warning level via the default logger.

Protected Member Functions

 Logger ()=default

Static Private Attributes

static LoggerdefaultLogger_ { nullptr }

Detailed Description

Abstract logging interface and static facade.

Concrete sinks derive from this class and implement the virtual log_* methods. The static convenience methods (info, warning, etc.) delegate to whichever sink has been registered via setDefaultLogger().

Calling any static log method before a sink has been registered via setDefaultLogger() is a programming error and will throw std::runtime_error. Register a NullSink in test harnesses that do not require log output.

Note
This class is not copyable or movable — sinks own resources (file handles, mutexes) that must not be duplicated.

Constructor & Destructor Documentation

◆ ~Logger()

virtual Mila::Logging::Logger::~Logger ( )
virtualdefault

◆ Logger() [1/3]

Mila::Logging::Logger::Logger ( const Logger & )
delete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Logger() [2/3]

Mila::Logging::Logger::Logger ( Logger && )
delete
Here is the call graph for this function:

◆ Logger() [3/3]

Mila::Logging::Logger::Logger ( )
protecteddefault

Member Function Documentation

◆ critical()

void Mila::Logging::Logger::critical ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Critical level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:

◆ debug()

void Mila::Logging::Logger::debug ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Debug level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:

◆ defaultLogger()

Logger & Mila::Logging::Logger::defaultLogger ( )
inlinestatic

Returns a reference to the registered default logger.

Exceptions
std::runtime_errorif no default logger has been registered. Call Mila::initialize() before making any log calls.
Returns
Reference to the active default logger.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ error()

void Mila::Logging::Logger::error ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Error level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLevel()

virtual LogLevel Mila::Logging::Logger::getLevel ( ) const
pure virtual

Returns the current minimum log level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

◆ info()

void Mila::Logging::Logger::info ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Info level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isEnabled()

virtual bool Mila::Logging::Logger::isEnabled ( LogLevel level) const
pure virtual

Returns true if records at level would be emitted.

Parameters
levelThe level to test.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

◆ log()

virtual void Mila::Logging::Logger::log ( std::string_view message,
LogLevel level,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at an explicitly specified level.

Parameters
messageThe pre-formatted log message.
levelThe severity level for this record.
locationAutomatically captured call-site location.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

◆ log_critical()

virtual void Mila::Logging::Logger::log_critical ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Critical level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ log_debug()

virtual void Mila::Logging::Logger::log_debug ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Debug level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ log_error()

virtual void Mila::Logging::Logger::log_error ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Error level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ log_info()

virtual void Mila::Logging::Logger::log_info ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Info level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ log_trace()

virtual void Mila::Logging::Logger::log_trace ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Trace level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ log_warning()

virtual void Mila::Logging::Logger::log_warning ( std::string_view message,
const std::source_location & location = std::source_location::current() )
pure virtual

Emits a record at Warning level.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

Here is the caller graph for this function:

◆ operator=() [1/2]

Logger & Mila::Logging::Logger::operator= ( const Logger & )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

Logger & Mila::Logging::Logger::operator= ( Logger && )
delete
Here is the call graph for this function:

◆ setDefaultLogger()

void Mila::Logging::Logger::setDefaultLogger ( Logger * logger)
inlinestatic

Registers a sink as the process-wide default logger.

The caller retains ownership. The pointer must remain valid for the lifetime of any subsequent log calls. Pass nullptr to deregister.

Parameters
loggerPointer to the sink to register, or nullptr to clear.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setLevel()

virtual void Mila::Logging::Logger::setLevel ( LogLevel level)
pure virtual

Sets the minimum level at which records are emitted.

Implemented in Mila::Logging::ConsoleSink, Mila::Logging::FileSink, and Mila::Logging::NullSink.

◆ trace()

void Mila::Logging::Logger::trace ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Trace level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:

◆ warning()

void Mila::Logging::Logger::warning ( std::string_view message,
const std::source_location & location = std::source_location::current() )
inlinestatic

Emits a record at Warning level via the default logger.

Parameters
messageThe pre-formatted log message.
locationAutomatically captured call-site location.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ defaultLogger_

Logger* Mila::Logging::Logger::defaultLogger_ { nullptr }
inlinestaticprivate

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