Expand description
Structured logging infrastructure for Smith platform
This crate provides high-performance, structured logging with NATS integration for centralized log collection across all Smith platform services.
§Features
- NATS Integration: Emit logs directly to NATS subjects for centralized collection
- Performance Optimized: Asynchronous logging with batching and buffering
- Structured Format: JSON logs with consistent fields and correlation IDs
- Configurable Filtering: Per-module, per-level filtering with target-based rules
- Graceful Fallback: Console logging when NATS is unavailable
- Rate Limiting: Prevent log flooding with configurable rate limits
§Usage
ⓘ
use smith_logging::{init_logging, LoggingLayer};
use smith_config::Config;
// Initialize logging with NATS integration
let config = Config::development();
let _guard = init_logging(&config.logging, &config.nats, "smith-core").await?;
// Use standard tracing macros
tracing::info!("Service started");
tracing::warn!("High memory usage detected");
tracing::error!("Database connection failed");Re-exports§
pub use error::LoggingError;pub use error::LoggingResult;
Modules§
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§
- LogEntry
- Structured log entry for NATS transmission
- LogMetadata
- Additional log metadata
- Logging
Guard - Guard that ensures proper cleanup of logging infrastructure
- Nats
Logging Layer - NATS logging layer for tracing-subscriber
- Span
Info - Span information for distributed tracing
- Trace
Info - Trace information
Functions§
- init_
console_ logging - Simplified initialization for testing
- init_
logging - Initialize logging with NATS integration