Skip to main content

Module debug

Module debug 

Source
Expand description

Unified debug logging system Unified Debug Logging System for Azul

This module provides a thread-safe debug logging infrastructure that can be passed through function arguments to collect debug messages during execution.

§Design Philosophy

  1. No global state for logging - All logging goes through explicit parameters
  2. Zero-cost when disabled - Option<&mut DebugLogger> is None in production
  3. Structured messages - Each message has level, category, and location
  4. Thread-safe collection - Can collect messages from multiple threads

§Usage Pattern

Functions that need debug logging accept debug_log: &mut Option<DebugLogger>:

fn do_layout(
    dom: &Dom,
    // ... other params ...
    debug_log: &mut Option<DebugLogger>,
) {
    log_debug!(debug_log, Layout, "Starting layout for {} nodes", dom.len());
    // ... do work ...
}

§Integration with HTTP Debug Server

When AZUL_DEBUG is set, the debug server creates a DebugLogger for each incoming request, which collects all messages until the frame is rendered, then returns them in the HTTP response.

Structs§

DebugLogger
Debug logger that collects messages during execution.
LogMessage
A structured log message for the debug logger

Enums§

DebugCategory
Categories for debug messages to enable filtering
DebugLevel
Debug message severity level

Functions§

debug_log
Helper function to conditionally log (when logger is Some)
get_debug_port
Get the debug server port from environment variable
is_debug_enabled
Check if debug mode is enabled via environment variable

Type Aliases§

DebugLog
Type alias for the debug logger parameter pattern used throughout the codebase