Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/momo5502/sogen/llms.txt

Use this file to discover all available pages before exploring further.

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

logger()
~logger() override
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.
void print(color c, std::string_view message) override
c
color
The color to use for the output
message
std::string_view
The message to print
Prints a formatted message with the specified color using printf-style formatting.
void print(color c, const char* message, ...) override
c
color
The color to use for the output
message
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.
void force_print(color c, const char* message, ...)
c
color
The color to use for the output
message
const char*
Printf-style format string
...
variadic
Arguments matching the format string

Severity-Specific Methods

Convenience methods for common logging levels.

info

void info(const char* message, ...) const
Logs informational messages in cyan.

warn

void warn(const char* message, ...) const
Logs warning messages in yellow.

error

void error(const char* message, ...) const
Logs error messages in red.

success

void success(const char* message, ...) const
Logs success messages in green.

log

void log(const char* message, ...) const
Logs general messages in white.

Output Control

disable_output

void disable_output(const bool value)
Enables or disables console output.
value
bool
true to disable output, false to enable
Note: The force_print method bypasses this setting.

is_output_disabled

bool is_output_disabled() const
Returns: true if output is currently disabled, false otherwise.

Color Enum

Available colors for terminal output:
enum class color
{
    black,
    red,
    green,
    yellow,
    blue,
    cyan,
    pink,
    white,
    gray,
    dark_gray,
}

Usage Example

#include <windows-emulator/logger.hpp>

logger log;

// Basic colored output
log.print(color::green, "Emulator started\n");

// Formatted output
log.info("Loading module at 0x%llx", base_address);
log.warn("Syscall %d not fully implemented", syscall_number);
log.error("Failed to allocate %zu bytes", size);
log.success("Process initialized with PID %d", pid);

// Conditional logging
if (verbose_mode) {
    log.log("Thread %d entering syscall", thread_id);
}

// Disable output temporarily
log.disable_output(true);
log.info("This won't be printed");
log.force_print(color::red, "But this will be!");
log.disable_output(false);

// Check output state
if (!log.is_output_disabled()) {
    log.print(color::cyan, "Output is enabled\n");
}

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

Build docs developers (and LLMs) love