![]() |
LogIt++
Header-only, macro-first C++ logging library
|
Exposes log metrics as Prometheus text exposition format via user-provided callback. More...
#include <PrometheusPayloadLogger.hpp>
Classes | |
| struct | Config |
Public Member Functions | |
| PrometheusPayloadLogger () | |
| Constructs Prometheus payload logger with default configuration. | |
| PrometheusPayloadLogger (const Config &config) | |
| Constructs Prometheus payload logger with custom configuration. | |
| ~PrometheusPayloadLogger () override=default | |
| PrometheusPayloadLogger (const PrometheusPayloadLogger &)=delete | |
| PrometheusPayloadLogger & | operator= (const PrometheusPayloadLogger &)=delete |
| void | log (const LogRecord &record, const std::string &message) override |
| Updates internal metric counters for a log message. | |
| void | wait () override |
| If emit_on_wait, collects metrics and invokes on_payload callback. | |
| void | shutdown () override |
| Stops the logger (no worker thread to drain for payload logger). | |
| std::string | collect_payload () |
| Collects current metrics and returns serialized Prometheus text payload. | |
| std::string | get_string_param (const LoggerParam ¶m) const override |
| Retrieves a string parameter from the logger. | |
| int64_t | get_int_param (const LoggerParam ¶m) const override |
| Retrieves an integer parameter from the logger. | |
| double | get_float_param (const LoggerParam ¶m) const override |
| Retrieves a floating-point parameter from the logger. | |
| void | set_log_level (LogLevel level) override |
| Sets minimal log level for this logger. | |
| LogLevel | get_log_level () const override |
| Gets minimal log level for this logger. | |
Public Member Functions inherited from logit::ILogger | |
| virtual | ~ILogger ()=default |
| 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. | |
Private Attributes | |
| Config | m_config |
| std::mutex | m_collect_mutex |
| PrometheusLoggerMetrics | m_metrics |
| std::atomic< int > | m_log_level = ATOMIC_VAR_INIT(static_cast<int>(LogLevel::LOG_LVL_TRACE)) |
Exposes log metrics as Prometheus text exposition format via user-provided callback.
This backend tracks internal counters and gauges (log records total, dropped, failed exports, last log timestamp, time since last log) and serializes them to Prometheus text exposition format. The payload is passed to a user-provided callback on wait() or on-demand via collect_payload().
Definition at line 33 of file PrometheusPayloadLogger.hpp.
|
inline |
Constructs Prometheus payload logger with default configuration.
Definition at line 44 of file PrometheusPayloadLogger.hpp.
|
inlineexplicit |
Constructs Prometheus payload logger with custom configuration.
| config | Export configuration. |
Definition at line 48 of file PrometheusPayloadLogger.hpp.
|
overridedefault |
|
delete |
|
inline |
Collects current metrics and returns serialized Prometheus text payload.
Definition at line 90 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Retrieves a floating-point parameter from the logger.
| param | Parameter to retrieve. |
Implements logit::ILogger.
Definition at line 141 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Retrieves an integer parameter from the logger.
| param | Parameter to retrieve. |
Implements logit::ILogger.
Definition at line 126 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Gets minimal log level for this logger.
Implements logit::ILogger.
Definition at line 165 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Retrieves a string parameter from the logger.
| param | Parameter to retrieve. |
Implements logit::ILogger.
Definition at line 111 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Updates internal metric counters for a log message.
| record | Structured log record. |
| message | Formatted log message (unused by Prometheus metrics). |
Implements logit::ILogger.
Definition at line 59 of file PrometheusPayloadLogger.hpp.
|
delete |
|
inlineoverridevirtual |
Sets minimal log level for this logger.
| level | Minimum log level. |
Implements logit::ILogger.
Definition at line 159 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
Stops the logger (no worker thread to drain for payload logger).
Implements logit::ILogger.
Definition at line 86 of file PrometheusPayloadLogger.hpp.
|
inlineoverridevirtual |
If emit_on_wait, collects metrics and invokes on_payload callback.
Implements logit::ILogger.
Definition at line 74 of file PrometheusPayloadLogger.hpp.
|
private |
Definition at line 171 of file PrometheusPayloadLogger.hpp.
|
private |
Definition at line 170 of file PrometheusPayloadLogger.hpp.
|
private |
Definition at line 174 of file PrometheusPayloadLogger.hpp.
|
private |
Definition at line 172 of file PrometheusPayloadLogger.hpp.