![]() |
LogIt++
Header-only, macro-first C++ logging library
|
Outputs formatted log messages to the Windows debug console or stderr. More...
#include <WindowsDebugLogger.hpp>
Classes | |
| struct | Config |
| Configuration for the Windows debug logger. More... | |
Public Member Functions | |
| WindowsDebugLogger () | |
| Default constructor that uses default configuration. | |
| WindowsDebugLogger (const Config &config) | |
| Constructor with custom configuration. | |
| WindowsDebugLogger (bool async, bool use_dedicated_executor, std::size_t queue_capacity, QueuePolicy queue_policy) | |
| Constructor with asynchronous and dedicated executor options. | |
| void | set_config (const Config &config) |
| Updates executor-related configuration at runtime. | |
| bool | set_queue_config (std::size_t queue_capacity, QueuePolicy queue_policy) |
| Updates queue_capacity and queue_policy at runtime without draining tasks. | |
| void | log (const LogRecord &record, const std::string &message) override |
| Logs a message to the Windows debug output or stderr. | |
| 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 the minimal log level for this logger. | |
| LogLevel | get_log_level () const override |
| Gets the minimal log level for this logger. | |
| void | wait () override |
| Waits for all asynchronous tasks to complete. | |
| void | shutdown () override |
| Stops logger-owned asynchronous resources after draining pending messages. | |
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. | |
Static Private Member Functions | |
| static Config | make_config (bool async, bool use_dedicated_executor, std::size_t queue_capacity, QueuePolicy queue_policy) |
| static void | write_impl (const std::string &message) |
Private Attributes | |
| Config | m_config |
| std::mutex | m_lifecycle_mutex |
| std::atomic< int > | m_log_level {static_cast<int>(LogLevel::LOG_LVL_TRACE)} |
| std::atomic< int64_t > | m_last_log_ts {0} |
| std::atomic< bool > | m_shutdown {false} |
| std::unique_ptr< detail::SingleThreadExecutor > | m_executor |
Outputs formatted log messages to the Windows debug console or stderr.
On Windows this logger forwards messages to OutputDebugStringW(), making them visible in Visual Studio Output, DebugView (Sysinternals), WinDbg and other debuggers. On non-Windows platforms it falls back to std::cerr.
Key Features:
Definition at line 33 of file WindowsDebugLogger.hpp.
|
inline |
Default constructor that uses default configuration.
Definition at line 58 of file WindowsDebugLogger.hpp.
|
inlineexplicit |
Constructor with custom configuration.
| config | The configuration for the logger. |
Definition at line 62 of file WindowsDebugLogger.hpp.
|
inline |
Constructor with asynchronous and dedicated executor options.
Definition at line 71 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Retrieves a floating-point parameter from the logger.
| param | The parameter type to retrieve. |
Implements logit::ILogger.
Definition at line 203 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Retrieves an integer parameter from the logger.
| param | The parameter type to retrieve. |
Implements logit::ILogger.
Definition at line 190 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Gets the minimal log level for this logger.
Implements logit::ILogger.
Definition at line 219 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Retrieves a string parameter from the logger.
| param | The parameter type to retrieve. |
Implements logit::ILogger.
Definition at line 177 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Logs a message to the Windows debug output or stderr.
If asynchronous logging is enabled, the message is added to the task queue; otherwise, it is logged directly.
| record | The log record containing log information. |
| message | The formatted log message. |
Implements logit::ILogger.
Definition at line 155 of file WindowsDebugLogger.hpp.
|
inlinestaticprivate |
Definition at line 255 of file WindowsDebugLogger.hpp.
|
inline |
Updates executor-related configuration at runtime.
This call is blocking. If asynchronous logging is currently enabled, it waits until already accepted tasks are drained before changing async mode or executor ownership. Only async, use_dedicated_executor, queue_capacity, and queue_policy are applied. Other fields in Config are ignored. For hot queue tuning without switching executor mode, use set_queue_config().
Definition at line 88 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Sets the minimal log level for this logger.
Implements logit::ILogger.
Definition at line 214 of file WindowsDebugLogger.hpp.
|
inline |
Updates queue_capacity and queue_policy at runtime without draining tasks.
| queue_capacity | New maximum queue size (0 = unlimited). |
| queue_policy | Overflow policy for the executor queue. |
Unlike set_config(), this method never blocks on task drain and never changes async mode or executor ownership. If no dedicated executor exists, only the stored config fields are updated for future reference.
Definition at line 128 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Stops logger-owned asynchronous resources after draining pending messages.
Implements logit::ILogger.
Definition at line 235 of file WindowsDebugLogger.hpp.
|
inlineoverridevirtual |
Waits for all asynchronous tasks to complete.
Implements logit::ILogger.
Definition at line 224 of file WindowsDebugLogger.hpp.
|
inlinestaticprivate |
Definition at line 267 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 248 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 253 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 251 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 249 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 250 of file WindowsDebugLogger.hpp.
|
private |
Definition at line 252 of file WindowsDebugLogger.hpp.