Logging Macros
Overview
Available Macros
trace_debug!(...) // Debug-level messages
trace_info!(...) // Informational messages
trace_warn!(...) // Warning messages
trace_error!(...) // Error messagesUsage
Basic Logging
use lighty_core::{trace_info, trace_error};
fn process_file(path: &str) {
trace_info!("Processing file: {}", path);
match std::fs::read(path) {
Ok(data) => {
trace_info!("File read successfully: {} bytes", data.len());
Ok(())
}
Err(e) => {
trace_error!("Failed to read file: {}", e);
Err(e.into())
}
}
}Structured Logging (with tracing feature)
Feature Flags
With tracing Feature
tracing FeatureWithout tracing Feature
tracing FeatureBest Practices
1. Use Appropriate Levels
2. Include Context
3. Don't Log Sensitive Data
See Also
Last updated