Expand description
Context management for structured logging with automatic cleanup.
Contexts provide a way to add key-value pairs that are automatically included
in all log messages. Use ContextGuard
for automatic cleanup when scope ends.
§Examples
use telelog::Logger;
let logger = Logger::new("app");
// Manual context management
logger.add_context("user_id", "12345");
logger.info("Processing request"); // includes user_id
logger.clear_context();
// Automatic cleanup with guard
{
let _guard = logger.with_context("request_id", "abc");
logger.info("Inside request"); // includes request_id
} // request_id automatically removed
Structs§
- Context
- A collection of key-value pairs that are included in log messages.
- Context
Guard - RAII guard that automatically removes a context key when dropped.