![]() |
LogIt++
Header-only, macro-first C++ logging library
|
The primary namespace for the LogIt++ library. More...
Namespaces | |
| namespace | detail |
Classes | |
| struct | BufferedLogEntry |
| Structured representation of a buffered log snapshot entry. More... | |
| class | ConsoleLogger |
| Outputs log messages to the console with optional ANSI color support. More... | |
| struct | ConsoleStreamRoute |
| Maps a log-level range to a target output stream. More... | |
| class | CrashPosixLogger |
| Stub implementation on non-POSIX platforms. More... | |
| class | CrashWindowsLogger |
| \class CrashWindowsLogger \brief Stub implementation on non-Windows platforms. More... | |
| class | EventLogLogger |
| Stub logger when Windows Event Log is unavailable. More... | |
| class | FileLogger |
| Logs messages to files with date-based rotation and automatic deletion of old logs. More... | |
| struct | FormatInstruction |
| Structure to store log formatting instructions. More... | |
| interface | ILogFormatter |
| Interface for formatting log records. More... | |
| interface | ILogger |
| Optional buffered snapshot access returns empty results by default. More... | |
| class | ILogReader |
| Optional interface for backends that expose stored records. More... | |
| class | ILogSubscriber |
| Optional interface for backends that can notify callers when a record is successfully written. More... | |
| struct | LogClearOptions |
| Selects which data categories a logger cleanup should remove. More... | |
| struct | LogClearResult |
| Result returned by logger cleanup operations. More... | |
| struct | LogFileInfo |
| Metadata for a persisted log file owned by a logger backend. More... | |
| struct | LogFileReadResult |
| Result of reading a persisted log file from a file-based backend. More... | |
| class | Logger |
| Singleton class managing multiple loggers and formatters. More... | |
| struct | LogRecord |
| Stores log metadata and content. More... | |
| struct | LogRecordSnapshot |
| Common owning snapshot of a stored log record. More... | |
| class | LogStream |
A stream-based logger that collects log messages using the << operator. More... | |
| class | MdbxLogger |
| Stores formatted logs in MDBX tables with optional async batching. More... | |
| class | MemoryLogger |
| Stores the latest formatted log messages in memory. More... | |
| class | OtlpHttpLogger |
| Exports logs to an OTLP/HTTP endpoint using kurlyk. More... | |
| struct | OtlpHttpLoggerState |
| struct | OtlpJsonFormatConfig |
| Serialization settings for OTLP JSON payload construction. More... | |
| struct | OtlpLogItem |
| Owns one formatted log message and its structured metadata. More... | |
| class | OtlpPayloadLogger |
| Exports logs as OTLP JSON payloads via a user-provided callback. More... | |
| struct | OtlpRecordSnapshot |
| Owns LogRecord fields required after original logging call returns. More... | |
| struct | PathComponents |
| Structure to hold the root and components of a path. More... | |
| class | PatternCompiler |
| Compiler for log formatting patterns. More... | |
| class | PrometheusHttpServerLogger |
| Serves Prometheus metrics via an embedded HTTP server. More... | |
| struct | PrometheusLabel |
| A single Prometheus label key-value pair. More... | |
| class | PrometheusLoggerMetrics |
| Tracks log-record counters and builds built-in Prometheus metric families. More... | |
| struct | PrometheusMetricFamily |
| A group of related samples sharing a name, help, and type. More... | |
| class | PrometheusPayloadLogger |
| Exposes log metrics as Prometheus text exposition format via user-provided callback. More... | |
| class | PrometheusRegistry |
| Stores custom gauge and counter callbacks for Prometheus collection. More... | |
| struct | PrometheusSample |
| A single metric sample with optional labels and timestamp. More... | |
| struct | PrometheusTextFormatConfig |
| Configuration for Prometheus text exposition format output. More... | |
| class | SimpleLogFormatter |
| A simple log formatter that formats log messages based on a user-defined pattern. More... | |
| class | SyslogLogger |
| Stub logger when syslog is unavailable. More... | |
| class | UniqueFileLogger |
| Writes each log message to a unique file with automatic cleanup. More... | |
| struct | VariableValue |
| Structure for storing values of various types, including enumerations. More... | |
| class | WindowsDebugLogger |
| Outputs formatted log messages to the Windows debug console or stderr. More... | |
Typedefs | |
| using | LoggerMutex = std::mutex |
| using | LoggerReadLock = std::unique_lock<LoggerMutex> |
| using | LoggerWriteLock = std::unique_lock<LoggerMutex> |
| using | QueuePolicy = detail::QueuePolicy |
| Public queue overflow handling policy. | |
| using | CrashLogger = CrashPosixLogger |
| using | SystemLogger = SyslogLogger |
| POSIX system logger alias. | |
| using | crev_it_t = std::string::const_reverse_iterator |
Enumerations | |
| enum class | LogLevel { LOG_LVL_TRACE , LOG_LVL_DEBUG , LOG_LVL_INFO , LOG_LVL_WARN , LOG_LVL_ERROR , LOG_LVL_FATAL } |
| Logging levels. More... | |
| enum class | TextColor { Black , DarkRed , DarkGreen , DarkYellow , DarkBlue , DarkMagenta , DarkCyan , LightGray , DarkGray , Red , Green , Yellow , Blue , Magenta , Cyan , White } |
| Text colors for console output. More... | |
| enum class | LoggerParam { LastFileName , LastFilePath , LastLogTimestamp , TimeSinceLastLog , DroppedLogCount , FailedExportCount } |
| Enumeration for different logger parameters that can be retrieved. More... | |
| enum class | CompressType { NONE , GZIP , ZSTD , EXTERNAL_CMD } |
| Supported compression algorithms for rotated files. More... | |
| enum class | RotationNaming { Sequence , Timestamp , TimestampMs } |
| Naming policy for rotated log files. More... | |
| enum class | ConsoleStreamKind { Cout , Cerr , Custom } |
| Identifies a target output stream for ConsoleLogger routes. More... | |
| enum class | LogClearStatus { Cleared , Unsupported , Failed } |
| Backend cleanup status. More... | |
| enum class | LogReadOrder { Ascending , Descending } |
| Ordering for query results returned by ILogReader. More... | |
| enum class | MdbxPayloadCompression { None = 0 , Gzip = 1 , Zstd = 2 } |
| Compression algorithm used for payload rows. More... | |
| enum class | OtlpCompression { None , Gzip , Zstd } |
| Compression algorithm used for an OTLP/HTTP request payload. More... | |
| enum class | PrometheusMetricType { Counter , Gauge , Untyped } |
| Prometheus metric type identifiers. More... | |
Functions | |
| const char * | to_c_str (LogLevel level, int mode=0) |
| Convert LogLevel to a C-style string representation. | |
| std::string | to_string (LogLevel level, int mode=0) |
| Convert LogLevel to a std::string representation. | |
| const char * | to_c_str (TextColor color) |
| Convert TextColor to a C-style string (ANSI escape codes). | |
| std::string | to_string (TextColor color) |
| Convert TextColor to a std::string (ANSI escape codes). | |
| std::string | get_log_level_color (LogLevel log_level) |
| Get the ANSI color code associated with a log level. | |
| std::string | otlp_json_escape (const std::string &value) |
| Escapes a string for JSON output. | |
| int | otlp_severity_number (LogLevel level) |
| Maps LogIt++ levels to OpenTelemetry severity numbers. | |
| void | otlp_write_comma_if_needed (std::ostringstream &os, bool &first) |
| Writes a comma before the next JSON value when needed. | |
| void | otlp_write_string_attr (std::ostringstream &os, const std::string &key, const std::string &value) |
| Writes a string OTLP attribute. | |
| void | otlp_write_int_attr (std::ostringstream &os, const std::string &key, int64_t value) |
| Writes an int OTLP attribute. | |
| void | otlp_write_bool_attr (std::ostringstream &os, const std::string &key, bool value) |
| Writes a bool OTLP attribute. | |
| void | otlp_write_double_attr (std::ostringstream &os, const std::string &key, double value) |
| Writes a double OTLP attribute. | |
| void | otlp_write_uint_attr (std::ostringstream &os, const std::string &key, uint64_t value) |
| Writes a uint64 OTLP attribute. | |
| std::string | sanitize_otlp_key (const std::string &name) |
| Sanitizes an attribute key for OTLP. | |
| void | otlp_write_log_record_json (std::ostringstream &os, const OtlpLogItem &item, const OtlpJsonFormatConfig &config) |
| Writes one OTLP JSON log record. | |
| std::string | build_otlp_logs_json_payload (const std::vector< OtlpLogItem > &batch, const OtlpJsonFormatConfig &config) |
| Builds an OTLP ExportLogsServiceRequest JSON payload. | |
| std::vector< std::string > | build_otlp_logs_json_payload_chunks (const std::vector< OtlpLogItem > &batch, const OtlpJsonFormatConfig &format, std::size_t max_payload_bytes) |
| Builds OTLP JSON payload chunks from a batch, splitting when a chunk would exceed max_payload_bytes. | |
| std::string | otlp_thread_id_to_string (const std::thread::id &id) |
| Converts thread id to a portable string representation. | |
| OtlpRecordSnapshot | make_otlp_record_snapshot (const LogRecord &record) |
| Creates an owned snapshot from a LogRecord. | |
| PrometheusLabel | make_prometheus_label (const std::string &name, const std::string &value) |
| Create a single label pair. | |
| PrometheusSample | make_prometheus_sample (const std::string &name, double value, std::vector< PrometheusLabel > labels={}, int64_t timestamp_ms=0) |
| Create a sample for a Prometheus metric family. | |
| PrometheusMetricFamily | make_prometheus_counter (const std::string &name, const std::string &help, double value) |
| Create a Counter metric family with one unlabeled sample. | |
| PrometheusMetricFamily | make_prometheus_counter (const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels) |
| Create a Counter metric family with one labeled sample. | |
| PrometheusMetricFamily | make_prometheus_gauge (const std::string &name, const std::string &help, double value) |
| Create a Gauge metric family with one unlabeled sample. | |
| PrometheusMetricFamily | make_prometheus_gauge (const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels) |
| Create a Gauge metric family with one labeled sample. | |
| PrometheusMetricFamily | make_prometheus_untyped (const std::string &name, const std::string &help, double value) |
| Create an Untyped metric family with one unlabeled sample. | |
| PrometheusMetricFamily | make_prometheus_untyped (const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels) |
| Create an Untyped metric family with one labeled sample. | |
| void | add_prometheus_counter (std::vector< PrometheusMetricFamily > &families, const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels={}) |
| Append a Counter metric family to the families vector (convenience for on_collect). | |
| void | add_prometheus_gauge (std::vector< PrometheusMetricFamily > &families, const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels={}) |
| Append a Gauge metric family to the families vector (convenience for on_collect). | |
| void | add_prometheus_untyped (std::vector< PrometheusMetricFamily > &families, const std::string &name, const std::string &help, double value, std::vector< PrometheusLabel > labels={}) |
| Append an Untyped metric family to the families vector (convenience for on_collect). | |
| std::string | prometheus_escape_help (const std::string &value) |
| Escapes help string for Prometheus text format. | |
| std::string | prometheus_escape_label_value (const std::string &value) |
| Escapes label value for Prometheus text format. | |
| std::string | prometheus_sanitize_metric_name (const std::string &name) |
| Sanitizes a metric name to match Prometheus naming rules. | |
| std::string | prometheus_sanitize_label_name (const std::string &name) |
| Sanitizes a label name to match Prometheus naming rules. | |
| void | prometheus_format_value (std::ostringstream &os, double value) |
| Formats a Prometheus sample value according to text format rules. | |
| void | prometheus_write_metric_family (std::ostringstream &os, const PrometheusMetricFamily &family, const PrometheusTextFormatConfig &config) |
| Writes one PrometheusMetricFamily to an output stream. | |
| std::string | build_prometheus_text_payload (const std::vector< PrometheusMetricFamily > &families, const PrometheusTextFormatConfig &config) |
| Builds a complete Prometheus text exposition format payload. | |
| std::vector< VariableValue > | args_to_array (std::vector< std::string >::const_iterator) |
| Base case of recursion for argument conversion — when there are no more arguments. | |
| template<typename T , typename... Ts> | |
| std::vector< VariableValue > | args_to_array (std::vector< std::string >::const_iterator name_iter, const T &first_arg, const Ts &... args) |
| Recursive function to convert arguments into an array of tuples (name, value). | |
| bool | is_closing_template (crev_it_t left_it, crev_it_t right_it) |
| Checks if the '>' character is the closing of a template argument list. | |
| std::vector< std::string > | split_arguments (const std::string &all_names) |
| Splits a string of argument names into individual names, ignoring nested templates, parentheses, and quotes. | |
| std::string | format (const char *fmt,...) |
| Formats a string according to the specified format. | |
| std::string | get_exec_dir () |
| Retrieves the directory of the executable file. | |
| std::vector< std::string > | get_list_files (const std::string &path) |
| Recursively retrieves a list of all files in a directory. | |
| std::string | get_file_name (const std::string &file_path) |
| Extracts the file name from a full file path. | |
| PathComponents | split_path (const std::string &path) |
| Splits a path into its root and components. | |
| std::string | make_relative (const std::string &file_path, const std::string &base_path) |
| Computes the relative path from base_path to file_path. | |
| bool | is_file (const std::string &path) |
| Checks if a path represents a file (by checking for an extension). | |
| void | create_directories (const std::string &path) |
| Creates directories recursively for the given path. | |
| template<typename EnumType > | |
| std::string | enum_to_string (EnumType value) |
| Helper function to convert an enumeration to a string. | |
| template<> | |
| std::string | enum_to_string (COLORS value) |
The primary namespace for the LogIt++ library.
\file CrashWindowsLogger.hpp \brief Windows crash logger persisting the last messages to a file handle.
\file CrashLogger.hpp \brief Platform-specific crash logger alias.
| using logit::CrashLogger = CrashPosixLogger |
Definition at line 16 of file CrashLogger.hpp.
| using logit::crev_it_t = std::string::const_reverse_iterator |
Definition at line 38 of file argument_utils.hpp.
| using logit::LoggerMutex = std::mutex |
Definition at line 33 of file Logger.hpp.
| using logit::LoggerReadLock = std::unique_lock<LoggerMutex> |
Definition at line 34 of file Logger.hpp.
| using logit::LoggerWriteLock = std::unique_lock<LoggerMutex> |
Definition at line 35 of file Logger.hpp.
Public queue overflow handling policy.
Definition at line 20 of file loggers.hpp.
| using logit::SystemLogger = SyslogLogger |
POSIX system logger alias.
Definition at line 17 of file SystemLogger.hpp.
|
strong |
|
strong |
Identifies a target output stream for ConsoleLogger routes.
| Enumerator | |
|---|---|
| Cout | Routes records to std::cout. |
| Cerr | Routes records to std::cerr. |
| Custom | Routes records to a caller-provided std::ostream pointer. |
Definition at line 14 of file ConsoleStreamRoute.hpp.
|
strong |
Backend cleanup status.
| Enumerator | |
|---|---|
| Cleared | |
| Unsupported | |
| Failed | |
Definition at line 27 of file ILogger.hpp.
|
strong |
Enumeration for different logger parameters that can be retrieved.
|
strong |
|
strong |
Ordering for query results returned by ILogReader.
| Enumerator | |
|---|---|
| Ascending | Oldest first. |
| Descending | Newest first. |
Definition at line 38 of file ILogReader.hpp.
|
strong |
Compression algorithm used for payload rows.
| Enumerator | |
|---|---|
| None | Store payload bytes as-is. |
| Gzip | Store gzip-compressed payload bytes. |
| Zstd | Store zstd-compressed payload bytes. |
Definition at line 23 of file MdbxLogger.hpp.
|
strong |
Compression algorithm used for an OTLP/HTTP request payload.
| Enumerator | |
|---|---|
| None | |
| Gzip | |
| Zstd | |
Definition at line 12 of file OtlpCompressionType.hpp.
|
strong |
Prometheus metric type identifiers.
| Enumerator | |
|---|---|
| Counter | |
| Gauge | |
| Untyped | |
Definition at line 16 of file PrometheusTextFormatConfig.hpp.
|
strong |
|
strong |
|
inline |
Append a Counter metric family to the families vector (convenience for on_collect).
Definition at line 122 of file PrometheusMetricBuilders.hpp.
|
inline |
Append a Gauge metric family to the families vector (convenience for on_collect).
Definition at line 132 of file PrometheusMetricBuilders.hpp.
|
inline |
Append an Untyped metric family to the families vector (convenience for on_collect).
Definition at line 142 of file PrometheusMetricBuilders.hpp.
| std::vector< VariableValue > logit::args_to_array | ( | std::vector< std::string >::const_iterator | name_iter, |
| const T & | first_arg, | ||
| const Ts &... | args ) |
Recursive function to convert arguments into an array of tuples (name, value).
| T | Type of the first argument. |
| Ts | Types of the remaining arguments. |
| name_iter | Iterator for the argument name list. |
| first_arg | The first argument. |
| args | The remaining arguments. |
Definition at line 27 of file argument_utils.hpp.
|
inline |
Base case of recursion for argument conversion — when there are no more arguments.
Definition at line 15 of file argument_utils.hpp.
|
inline |
Builds an OTLP ExportLogsServiceRequest JSON payload.
| batch | Log batch to serialize. |
| config | Export configuration. |
Definition at line 299 of file OtlpJsonSerializer.hpp.
|
inline |
Builds OTLP JSON payload chunks from a batch, splitting when a chunk would exceed max_payload_bytes.
| batch | Log items to serialize. |
| format | Serialization configuration. |
| max_payload_bytes | Maximum serialized size per chunk (0 = no splitting). |
Definition at line 20 of file OtlpPayloadSplitter.hpp.
|
inline |
Builds a complete Prometheus text exposition format payload.
| families | Metric families to serialize. |
| config | Format configuration. |
Definition at line 200 of file PrometheusTextSerializer.hpp.
|
inline |
Creates directories recursively for the given path.
| path | The directory path to create. |
| std::runtime_error | if the directories cannot be created. |
Definition at line 394 of file path_utils.hpp.
| std::string logit::enum_to_string | ( | COLORS | value | ) |
Definition at line 46 of file example_logit_basic.cpp.
| std::string logit::enum_to_string | ( | EnumType | value | ) |
Helper function to convert an enumeration to a string.
| EnumType | The enumeration type. |
| value | The enumeration value. |
Definition at line 34 of file VariableValue.hpp.
|
inline |
Formats a string according to the specified format.
This function uses a vsnprintf-based implementation.
| fmt | The format string (similar to printf format). |
| ... | A variable number of arguments matching the format string. |
Definition at line 22 of file format.hpp.
|
inline |
Retrieves the directory of the executable file.
Definition at line 72 of file path_utils.hpp.
|
inline |
Extracts the file name from a full file path.
| file_path | The full file path as a string. |
Definition at line 226 of file path_utils.hpp.
|
inline |
Recursively retrieves a list of all files in a directory.
| path | The directory path to search (UTF-8 encoded). |
Definition at line 141 of file path_utils.hpp.
|
inline |
Checks if the '>' character is the closing of a template argument list.
| left_it | Iterator pointing to the '>' character. |
| right_it | Iterator pointing to the end of the string. |
Definition at line 44 of file argument_utils.hpp.
|
inline |
Checks if a path represents a file (by checking for an extension).
| path | The path to check. |
Definition at line 385 of file path_utils.hpp.
|
inline |
Creates an owned snapshot from a LogRecord.
| record | Source log record. |
Definition at line 46 of file OtlpRecordSnapshot.hpp.
|
inline |
Create a Counter metric family with one unlabeled sample.
Definition at line 41 of file PrometheusMetricBuilders.hpp.
|
inline |
Create a Counter metric family with one labeled sample.
Definition at line 54 of file PrometheusMetricBuilders.hpp.
|
inline |
Create a Gauge metric family with one unlabeled sample.
Definition at line 68 of file PrometheusMetricBuilders.hpp.
|
inline |
Create a Gauge metric family with one labeled sample.
Definition at line 81 of file PrometheusMetricBuilders.hpp.
|
inline |
Create a single label pair.
Definition at line 17 of file PrometheusMetricBuilders.hpp.
|
inline |
Create a sample for a Prometheus metric family.
Definition at line 27 of file PrometheusMetricBuilders.hpp.
|
inline |
Create an Untyped metric family with one unlabeled sample.
Definition at line 95 of file PrometheusMetricBuilders.hpp.
|
inline |
Create an Untyped metric family with one labeled sample.
Definition at line 108 of file PrometheusMetricBuilders.hpp.
|
inline |
Computes the relative path from base_path to file_path.
| file_path | The target file path. |
| base_path | The base path from which to compute the relative path. |
Definition at line 331 of file path_utils.hpp.
|
inline |
Escapes a string for JSON output.
| value | Input string. |
Definition at line 32 of file OtlpJsonSerializer.hpp.
|
inline |
Maps LogIt++ levels to OpenTelemetry severity numbers.
| level | LogIt++ severity level. |
Definition at line 66 of file OtlpJsonSerializer.hpp.
|
inline |
Converts thread id to a portable string representation.
| id | Thread id to convert. |
Definition at line 37 of file OtlpRecordSnapshot.hpp.
|
inline |
Writes a bool OTLP attribute.
| os | Output stream. |
| key | Attribute key. |
| value | Attribute boolean value. |
Definition at line 110 of file OtlpJsonSerializer.hpp.
|
inline |
Writes a comma before the next JSON value when needed.
| os | Output stream. |
| first | First-item flag to update. |
Definition at line 81 of file OtlpJsonSerializer.hpp.
|
inline |
Writes a double OTLP attribute.
| os | Output stream. |
| key | Attribute key. |
| value | Attribute double value. |
Definition at line 119 of file OtlpJsonSerializer.hpp.
|
inline |
Writes an int OTLP attribute.
| os | Output stream. |
| key | Attribute key. |
| value | Attribute integer value. |
Definition at line 101 of file OtlpJsonSerializer.hpp.
|
inline |
Writes one OTLP JSON log record.
| os | Output stream. |
| item | Log item to serialize. |
| config | Export configuration. |
Definition at line 161 of file OtlpJsonSerializer.hpp.
|
inline |
Writes a string OTLP attribute.
| os | Output stream. |
| key | Attribute key. |
| value | Attribute string value. |
Definition at line 92 of file OtlpJsonSerializer.hpp.
|
inline |
Writes a uint64 OTLP attribute.
| os | Output stream. |
| key | Attribute key. |
| value | Attribute uint64 value. |
Definition at line 135 of file OtlpJsonSerializer.hpp.
|
inline |
Escapes help string for Prometheus text format.
| value | Raw help string. |
Definition at line 24 of file PrometheusTextSerializer.hpp.
|
inline |
Escapes label value for Prometheus text format.
| value | Raw label value. |
Definition at line 43 of file PrometheusTextSerializer.hpp.
|
inline |
Formats a Prometheus sample value according to text format rules.
| os | Output stream. |
| value | Double value to format. |
Definition at line 120 of file PrometheusTextSerializer.hpp.
|
inline |
Sanitizes a label name to match Prometheus naming rules.
| name | Raw label name. |
Definition at line 92 of file PrometheusTextSerializer.hpp.
|
inline |
Sanitizes a metric name to match Prometheus naming rules.
| name | Raw metric name. |
Definition at line 64 of file PrometheusTextSerializer.hpp.
|
inline |
Writes one PrometheusMetricFamily to an output stream.
| os | Output string stream. |
| family | Metric family to write. |
| config | Format configuration. |
Definition at line 138 of file PrometheusTextSerializer.hpp.
|
inline |
Sanitizes an attribute key for OTLP.
| name | Raw key name. |
Definition at line 147 of file OtlpJsonSerializer.hpp.
|
inline |
Splits a string of argument names into individual names, ignoring nested templates, parentheses, and quotes.
| all_names | The string containing all argument names. |
Definition at line 62 of file argument_utils.hpp.
|
inline |
Splits a path into its root and components.
| path | The path to split. |
Definition at line 287 of file path_utils.hpp.
|
inline |
|
inline |
|
inline |