rsnaker/game_logic/logger/mod.rs
1//! # Dynamic Logging Configuration System
2//!
3//! This module provides an asynchronous, non-blocking logging infrastructure
4//! that can have its logging level dynamically updated at runtime. It is built
5//! on top of the `tracing` ecosystem.
6//!
7//! ## Core Features
8//! - **Non-blocking I/O:** Log events are pushed onto an in-memory ring buffer and written
9//! to disk by a dedicated background worker thread, ensuring the main application threads
10//! never stall due to disk writes.
11//! - **Hot Reloading:** The active log level (`INFO`, `DEBUG`, etc.) can be modified on the fly
12//! without restarting the application, using a global `reload::Handle`.
13//! - **File Rotation:** Uses `tracing_appender` to centralize all application logs into a local file.
14//!
15//! ## Example Usage
16//! ```rust
17//! use rsnaker::game_logic::logger::log_configuration::{init_logger, update_log_level, LogLevel};
18//! use tracing::{info, span, Level};
19//! // 1. Initialize the global logger (keep the guard alive!)
20//! let _guard = init_logger(LogLevel::Info, "test_log.log");
21//!
22//! info!("This log is visible at Info level.");
23//!
24//! // 2. Change the log level dynamically later in execution
25//! update_log_level(LogLevel::Debug);
26//!
27//! // 3. Using a Span to capture a specific context/timed window
28//! // Creates a new span named "game_session" with a dynamic property
29//! let session_span = span!(Level::INFO, "game_session", session_id = 12345);
30//!
31//! // Enters the span. The context is active until `_enter` goes out of scope.
32//! let _enter = session_span.enter();
33//!
34//! // This log occurs *inside* the span.
35//! // Because our config has `.with_file(true)` and `.with_line_number(true)`,
36//! // the output file will automatically include the filename, line number,
37//! // AND the context: `game_session{session_id=12345}`
38//! info!("Player spawned successfully into the game loop.");
39//!
40//! // The span automatically closes here when `_enter` is dropped.
41//! ```
42//!
43pub mod log_configuration;