Skip to main content
The logger class provides console output with color support and formatted printing capabilities for debugging and diagnostics.

Overview

This class extends generic_logger to provide:
  • Colored console output with multiple severity levels
  • Printf-style formatted printing with type safety
  • Output control for suppressing logs
  • Cross-platform terminal color support
  • Forced printing that bypasses output controls

Constructor & Destructor

On Windows, the constructor saves the current console code page and sets UTF-8 mode. The destructor restores the original code page.

Methods

Prints a message with the specified color.
color
The color to use for the output
std::string_view
The message to print
Prints a formatted message with the specified color using printf-style formatting.
color
The color to use for the output
const char*
Printf-style format string
variadic
Arguments matching the format string
Note: This method respects the output disabled flag.

force_print

Prints a formatted message that bypasses the output disabled flag.
color
The color to use for the output
const char*
Printf-style format string
variadic
Arguments matching the format string

Severity-Specific Methods

Convenience methods for common logging levels.

info

Logs informational messages in cyan.

warn

Logs warning messages in yellow.

error

Logs error messages in red.

success

Logs success messages in green.

log

Logs general messages in white.

Output Control

disable_output

Enables or disables console output.
bool
true to disable output, false to enable
Note: The force_print method bypasses this setting.

is_output_disabled

Returns: true if output is currently disabled, false otherwise.

Color Enum

Available colors for terminal output:

Usage Example

Platform Notes

  • Windows: Automatically manages console code page for UTF-8 support
  • Unix/Linux: Uses ANSI escape codes for color output
  • Format string safety is enforced via compiler attributes on GCC/Clang

See Also