LogIt++
Header-only, macro-first C++ logging library
Loading...
Searching...
No Matches
logit::ILogger Interface Referenceabstract

Optional buffered snapshot access returns empty results by default. More...

#include <ILogger.hpp>

Inheritance diagram for logit::ILogger:
logit::ConsoleLogger logit::CrashPosixLogger logit::CrashWindowsLogger logit::EventLogLogger logit::FileLogger logit::MdbxLogger logit::MemoryLogger logit::OtlpHttpLogger logit::OtlpPayloadLogger logit::PrometheusHttpServerLogger logit::PrometheusPayloadLogger logit::SyslogLogger logit::UniqueFileLogger logit::WindowsDebugLogger

Public Member Functions

virtual ~ILogger ()=default
 
virtual void log (const LogRecord &record, const std::string &message)=0
 Logs a message.
 
virtual std::string get_string_param (const LoggerParam &param) const =0
 Retrieves a string parameter from the logger.
 
virtual int64_t get_int_param (const LoggerParam &param) const =0
 Retrieves an integer parameter from the logger.
 
virtual double get_float_param (const LoggerParam &param) const =0
 Retrieves a floating-point parameter from the logger.
 
virtual void set_log_level (LogLevel level)=0
 Sets the minimal log level for this logger.
 
virtual LogLevel get_log_level () const =0
 Gets the minimal log level for this logger.
 
virtual std::vector< std::string > get_buffered_strings () const
 Returns buffered formatted messages in chronological order.
 
virtual std::vector< BufferedLogEntry > get_buffered_entries () const
 Returns buffered structured entries in chronological order.
 
virtual std::vector< LogFileInfo > list_log_files () const
 Lists persisted log files owned by this backend.
 
virtual LogFileReadResult read_log_file (const std::string &path) const
 Reads one persisted log file owned by this backend.
 
virtual std::vector< LogFileReadResult > read_log_files (const std::vector< std::string > &paths) const
 Reads several persisted log files owned by this backend.
 
virtual LogClearResult clear_logs (const LogClearOptions &options=LogClearOptions())
 Clears logger-owned buffered or persisted records when supported.
 
virtual void wait ()=0
 Waits for all asynchronous logging operations to complete.
 
virtual void shutdown ()
 Stops logger-owned asynchronous resources after draining pending work.
 

Detailed Description

Optional buffered snapshot access returns empty results by default.

Custom loggers may override these methods when they keep recent history.

Interface for loggers that handle log message output.

Definition at line 47 of file ILogger.hpp.

Constructor & Destructor Documentation

◆ ~ILogger()

virtual logit::ILogger::~ILogger ( )
virtualdefault

Member Function Documentation

◆ clear_logs()

virtual LogClearResult logit::ILogger::clear_logs ( const LogClearOptions & options = LogClearOptions())
inlinevirtual

Clears logger-owned buffered or persisted records when supported.

Parameters
optionsData categories to clear.
Returns
Cleanup result. Default reports unsupported.

Implemented in logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, and logit::UniqueFileLogger.

Definition at line 140 of file ILogger.hpp.

◆ get_buffered_entries()

virtual std::vector< BufferedLogEntry > logit::ILogger::get_buffered_entries ( ) const
inlinevirtual

Returns buffered structured entries in chronological order.

Override only if the logger keeps recent history and can safely serve snapshots while log() may run concurrently.

Returns
Buffered entries, or an empty vector if unsupported.

Implemented in logit::MemoryLogger.

Definition at line 98 of file ILogger.hpp.

◆ get_buffered_strings()

virtual std::vector< std::string > logit::ILogger::get_buffered_strings ( ) const
inlinevirtual

Returns buffered formatted messages in chronological order.

Override only if the logger keeps recent history and can safely serve snapshots while log() may run concurrently.

Returns
Buffered messages, or an empty vector if unsupported.

Implemented in logit::MemoryLogger.

Definition at line 90 of file ILogger.hpp.

◆ get_float_param()

virtual double logit::ILogger::get_float_param ( const LoggerParam & param) const
pure virtual

Retrieves a floating-point parameter from the logger.

Derived classes should implement this to return specific floating-point-based parameters.

Parameters
paramThe parameter type to retrieve.
Returns
A double representing the requested parameter.

Implemented in logit::ConsoleLogger, logit::CrashPosixLogger, logit::CrashWindowsLogger, logit::EventLogLogger, logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::SyslogLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.

◆ get_int_param()

virtual int64_t logit::ILogger::get_int_param ( const LoggerParam & param) const
pure virtual

Retrieves an integer parameter from the logger.

Derived classes should implement this to return specific integer-based parameters.

Parameters
paramThe parameter type to retrieve.
Returns
An integer representing the requested parameter.

Implemented in logit::ConsoleLogger, logit::CrashPosixLogger, logit::CrashWindowsLogger, logit::EventLogLogger, logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::SyslogLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.

◆ get_log_level()

◆ get_string_param()

virtual std::string logit::ILogger::get_string_param ( const LoggerParam & param) const
pure virtual

Retrieves a string parameter from the logger.

Derived classes should implement this to return specific string-based parameters.

Parameters
paramThe parameter type to retrieve.
Returns
A string representing the requested parameter.

Implemented in logit::ConsoleLogger, logit::CrashPosixLogger, logit::CrashWindowsLogger, logit::EventLogLogger, logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::SyslogLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.

◆ list_log_files()

virtual std::vector< LogFileInfo > logit::ILogger::list_log_files ( ) const
inlinevirtual

Lists persisted log files owned by this backend.

Override only for file-based backends that can safely enumerate their own persisted files while log() may run concurrently.

Returns
File metadata list, or an empty vector if unsupported.

Implemented in logit::FileLogger, and logit::UniqueFileLogger.

Definition at line 107 of file ILogger.hpp.

◆ log()

virtual void logit::ILogger::log ( const LogRecord & record,
const std::string & message )
pure virtual

Logs a message.

This pure virtual function must be implemented by derived logger classes. It handles the logging of messages, which could be output to a console, file, or other destinations.

Parameters
recordThe log record containing details about the log event.
messageThe formatted log message.

Implemented in logit::ConsoleLogger, logit::CrashPosixLogger, logit::CrashWindowsLogger, logit::EventLogLogger, logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::SyslogLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.

◆ read_log_file()

virtual LogFileReadResult logit::ILogger::read_log_file ( const std::string & path) const
inlinevirtual

Reads one persisted log file owned by this backend.

This API is intended for persisted-file access only. It must not drain async queues or wait for pending writes to finish.

Parameters
pathFull path returned by list_log_files().
Returns
Read result. ok is false when unsupported or unavailable.

Implemented in logit::FileLogger, and logit::UniqueFileLogger.

Definition at line 116 of file ILogger.hpp.

◆ read_log_files()

virtual std::vector< LogFileReadResult > logit::ILogger::read_log_files ( const std::vector< std::string > & paths) const
inlinevirtual

Reads several persisted log files owned by this backend.

Default implementation preserves request order by calling read_log_file() for each requested path.

Parameters
pathsFull paths returned by list_log_files().
Returns
Per-file results in the same order as paths.

Implemented in logit::FileLogger, and logit::UniqueFileLogger.

Definition at line 128 of file ILogger.hpp.

◆ set_log_level()

◆ shutdown()

virtual void logit::ILogger::shutdown ( )
inlinevirtual

Stops logger-owned asynchronous resources after draining pending work.

Custom loggers may override this when they own worker threads or queues. The default implementation preserves the existing custom logger contract by delegating to wait().

Implemented in logit::ConsoleLogger, logit::FileLogger, logit::MdbxLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.

Definition at line 159 of file ILogger.hpp.

◆ wait()

virtual void logit::ILogger::wait ( )
pure virtual

Waits for all asynchronous logging operations to complete.

This pure virtual function must be implemented by derived logger classes. It ensures that any pending log messages are fully processed, especially when logging asynchronously.

Implemented in logit::ConsoleLogger, logit::CrashPosixLogger, logit::CrashWindowsLogger, logit::EventLogLogger, logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, logit::OtlpHttpLogger, logit::OtlpPayloadLogger, logit::PrometheusHttpServerLogger, logit::PrometheusPayloadLogger, logit::SyslogLogger, logit::UniqueFileLogger, and logit::WindowsDebugLogger.


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