Skip to main content

Module logging

Module logging 

Source
Expand description

Unified logging and observability for the rust-ai ecosystem.

§Why This Module Exists

ML training and inference generate massive amounts of diagnostic data:

  • Training progress (loss, learning rate, throughput)
  • Memory usage and allocation patterns
  • Device information and kernel timings
  • Errors and warnings

Without consistent logging configuration, each crate would implement its own approach, leading to inconsistent output formats and configuration mechanisms.

This module provides:

  1. Unified log initialization: Single function to configure logging for all crates
  2. Structured logging helpers: Consistent field names for metrics and events
  3. Progress tracking: Training loop progress bars and ETA estimation

§Design Decisions

  • tracing-based: Uses the tracing ecosystem for structured logging with spans
  • Environment-driven: Log levels configured via RUST_LOG environment variable
  • Zero-cost when disabled: All logging compiles to no-ops when level is filtered

Macros§

debug
Constructs an event at the debug level.
error
Constructs an event at the error level.
info
Constructs an event at the info level.
trace
Constructs an event at the trace level.
warn
Constructs an event at the warn level.

Structs§

LogConfig
Configuration for logging initialization.

Enums§

LogLevel
Log level enumeration.

Functions§

init_logging
Initialize logging for the rust-ai ecosystem.
log_memory_usage
Log memory usage.
log_training_step
Log a training step with standard fields.