Files
unshell/src/logger/mod.rs
T

51 lines
1.2 KiB
Rust
Raw Normal View History

//! # Logger Module
//!
2026-04-24 14:32:59 -06:00
//! Lightweight logging primitives for `no_std` environments.
//!
2026-04-24 14:32:59 -06:00
//! The logger stays intentionally small:
//! - call sites use exported `debug!`, `info!`, `warn!`, and `error!` macros
//! - sinks implement [`Logger`]
//! - startup code installs a single global logger with [`set_logger`]
//!
2026-04-24 14:32:59 -06:00
//! ## Quick start
//!
2026-04-24 13:37:30 -06:00
//! ```rust
2026-04-24 14:32:59 -06:00
//! use unshell::{error, info, warn};
//! use unshell::logger::{Logger, Record, set_logger};
//!
2026-04-24 14:32:59 -06:00
//! struct Sink;
2026-04-24 13:37:30 -06:00
//!
2026-04-24 14:32:59 -06:00
//! impl Logger for Sink {
//! fn log(&self, record: &Record<'_>) {
2026-04-24 13:37:30 -06:00
//! let _ = record;
//! }
//! }
//!
2026-04-24 14:32:59 -06:00
//! static LOGGER: Sink = Sink;
//! set_logger(&LOGGER);
//!
2026-04-24 14:32:59 -06:00
//! info!("starting up");
//! warn!("slow path engaged");
//! error!("critical failure");
//! ```
//!
2026-04-24 14:32:59 -06:00
//! ## Design notes
//!
2026-04-24 14:32:59 -06:00
//! The global sink is installed once at startup and then treated as immutable.
//! That contract lets the module stay `no_std` while still providing a simple
//! global logging API.
2026-04-24 14:32:59 -06:00
mod global;
mod level;
mod macros;
mod record;
mod sink;
2026-04-24 14:32:59 -06:00
#[cfg(test)]
mod tests;
2026-04-24 14:32:59 -06:00
pub use global::{global_logger, log, set_logger};
pub use level::LogLevel;
pub use record::Record;
pub use sink::{CompatibilityLogger, Logger};