-
Notifications
You must be signed in to change notification settings - Fork 2
Console Output
logme supports colored console output on both Linux and Windows.
Color handling is designed to work correctly across different console capabilities and operating system versions.
Console color output in logme works in two modes:
- Classic console colors (16 colors)
- ANSI / VT mode (extended formatting)
By default, only classic console coloring is enabled. ANSI / VT mode must be enabled explicitly.
Both modes are supported on Windows. Linux uses ANSI sequences natively.
To enable ANSI / VT processing on Windows, the application must explicitly request it:
Logme::Instance->SetEnableVTMode(true);If VT mode is successfully enabled:
- ANSI escape sequences are supported
- Extended colors become available
- Text attributes such as underline and bold can be used
If VT mode is not enabled or not supported:
- Output falls back to classic console coloring
- ANSI escape sequences are automatically stripped
Even if VT mode is not enabled, logme still supports:
- 16-color console output
- Automatic severity-based coloring
- Colored warnings and errors
In this mode:
- Colors are applied using native Windows console APIs
- ANSI escape sequences are not required
- Automatic coloring works transparently
Severity-based coloring:
- Info — default console color
- Warning — yellow
- Error / Critical — red
Automatic severity-based coloring can be disabled.
This is controlled by OutputFlags.Highlight (console backend only).
If Highlight is disabled:
- No automatic coloring based on severity is applied
- User-provided ANSI formatting (if VT mode is enabled) still works
This allows precise control over visual output, especially when console colors are managed externally.
On Linux:
- ANSI escape sequences are supported natively
- VT mode handling is not required
- Extended colors and formatting work out of the box
Applications may include ANSI color sequences directly in log messages.
To use predefined ANSI constants, include:
#include <Logme/AnsiColorEscape.h>Example:
LogmeI(
ANSI_LIGHT_GREEN "green text "
ANSI_YELLOW "yellow "
ANSI_RESET "normal"
);When VT mode is enabled:
- Colors and attributes are rendered as specified
When VT mode is disabled:
- ANSI sequences are removed automatically
The Console backend supports flexible routing of log messages between
stdout and stderr using ConsoleStream in OutputFlags.
This allows correct integration with shells, supervisors, and log collectors.
logme — flexible runtime logging system
Home · Getting Started · Architecture · Output · Backends · Configuration
GitHub: https://github.com/efmsoft/logme