![]() |
LogIt++
Header-only, macro-first C++ logging library
|
Optional buffered snapshot access returns empty results by default. More...
#include <ILogger.hpp>
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 ¶m) const =0 |
| Retrieves a string parameter from the logger. | |
| virtual int64_t | get_int_param (const LoggerParam ¶m) const =0 |
| Retrieves an integer parameter from the logger. | |
| virtual double | get_float_param (const LoggerParam ¶m) 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. | |
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.
|
virtualdefault |
|
inlinevirtual |
Clears logger-owned buffered or persisted records when supported.
| options | Data categories to clear. |
Implemented in logit::FileLogger, logit::MdbxLogger, logit::MemoryLogger, and logit::UniqueFileLogger.
Definition at line 140 of file ILogger.hpp.
|
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.
Implemented in logit::MemoryLogger.
Definition at line 98 of file ILogger.hpp.
|
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.
Implemented in logit::MemoryLogger.
Definition at line 90 of file ILogger.hpp.
|
pure virtual |
Retrieves a floating-point parameter from the logger.
Derived classes should implement this to return specific floating-point-based parameters.
| param | The parameter type to retrieve. |
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.
|
pure virtual |
Retrieves an integer parameter from the logger.
Derived classes should implement this to return specific integer-based parameters.
| param | The parameter type to retrieve. |
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.
|
pure virtual |
Gets the minimal log level for this logger.
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.
|
pure virtual |
Retrieves a string parameter from the logger.
Derived classes should implement this to return specific string-based parameters.
| param | The parameter type to retrieve. |
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.
|
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.
Implemented in logit::FileLogger, and logit::UniqueFileLogger.
Definition at line 107 of file ILogger.hpp.
|
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.
| record | The log record containing details about the log event. |
| message | The 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.
|
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.
| path | Full path returned by list_log_files(). |
ok is false when unsupported or unavailable. Implemented in logit::FileLogger, and logit::UniqueFileLogger.
Definition at line 116 of file ILogger.hpp.
|
inlinevirtual |
Reads several persisted log files owned by this backend.
Default implementation preserves request order by calling read_log_file() for each requested path.
| paths | Full paths returned by list_log_files(). |
paths. Implemented in logit::FileLogger, and logit::UniqueFileLogger.
Definition at line 128 of file ILogger.hpp.
|
pure virtual |
Sets the minimal log level for this logger.
| level | Minimum log level. |
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.
|
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.
|
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.