Skip to main content

Module logging

Module logging 

Source
Expand description

§Structured Logging for Thread Flow

Production-ready logging infrastructure with multiple output formats and log levels.

§Features

  • Multiple Formats: JSON (production) and human-readable (development)
  • Contextual Logging: Automatic span tracking with tracing
  • Performance Tracking: Built-in duration tracking for operations
  • Error Context: Rich error context with backtraces

§Usage

use thread_flow::monitoring::logging::{init_logging, LogConfig, LogLevel, LogFormat};

// Initialize logging (call once at startup)
init_logging(LogConfig {
    level: LogLevel::Info,
    format: LogFormat::Json,
    ..Default::default()
})?;

// Use macros for logging
info!("Processing file", file = "src/main.rs");
warn!("Cache miss", hash = "abc123...");
error!("Database connection failed", error = %err);

// Structured logging with spans
let span = info_span!("analyze_file", file = "src/main.rs");
let _guard = span.enter();
// All logs within this scope will include file context

Modules§

structured
Structured logging helpers

Structs§

LogConfig
Logging configuration

Enums§

LogFormat
Log output format
LogLevel
Log level configuration
LoggingError
Logging errors

Functions§

init_cli_logging
Initialize logging for CLI applications
init_logging
Initialize logging infrastructure
init_production_logging
Initialize logging for production/edge deployments