Skip to main content

Crate smith_logging

Crate smith_logging 

Source
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§

error
Error types for Smith logging infrastructure
metrics
Metrics for Smith logging infrastructure

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
LoggingGuard
Guard that ensures proper cleanup of logging infrastructure
NatsLoggingLayer
NATS logging layer for tracing-subscriber
SpanInfo
Span information for distributed tracing
TraceInfo
Trace information

Functions§

init_console_logging
Simplified initialization for testing
init_logging
Initialize logging with NATS integration