Expand description
Per-session structured logging
This module provides session-aware structured logging for all protocol servers (SMTP, IMAP, POP3, JMAP). Each connection gets a unique session ID that is attached to all log events, making it easy to trace and debug individual sessions.
§Features
- Unique session IDs (UUID v4)
- Session context with client IP, protocol, and user information
- Integration with tracing-subscriber for structured logging
- Helper macros for convenient session-aware logging
- Automatic span management per session
§Example
use rusmes_server::session_logging::{SessionContext, SessionLogger};
use std::net::IpAddr;
let session = SessionContext::new(
IpAddr::from([127, 0, 0, 1]),
"SMTP",
);
let logger = SessionLogger::new(session);
let _guard = logger.enter();
// All logs within this span will include session context
tracing::info!("Connection established");Structs§
- Session
Context - Session context for structured logging
- Session
Logger - Session-aware logger that wraps tracing spans
Functions§
- format_
session_ header - Helper function to format session context for response headers
- format_
session_ json - Create a JSON representation of session context