Expand description
Logging infrastructure for vanguards-rs.
This module provides logging functionality using the tracing ecosystem. It supports output to stdout, files, and syslog, with configurable log levels.
§Overview
The logging system provides:
- Multiple output destinations: stdout, file, or syslog
- Configurable log levels: From DEBUG to ERROR
- Python vanguards compatibility:
plogfunction matches Python API - Environment variable override:
RUST_LOGcan override configured level
§Log Levels
From most to least verbose:
| Level | Description | Use Case |
|---|---|---|
Debug | Low-level debugging | Development only |
Info | Informational messages | Verbose operation |
Notice | Notable events | Default level |
Warn | Warning conditions | Potential issues |
Error | Error conditions | Failures |
§Example
use vanguards_rs::{LogLevel, logger};
// Initialize logging to stdout at NOTICE level
logger::init(LogLevel::Notice, None).unwrap();
// Log messages using the plog function
logger::plog(LogLevel::Notice, "Vanguards started");
logger::plog(LogLevel::Info, "Connected to Tor");
logger::plog(LogLevel::Warn, "High timeout rate detected");§Output Destination Examples
use vanguards_rs::{LogLevel, logger};
// Log to stdout (default)
logger::init(LogLevel::Notice, None).unwrap();
// Log to a file
logger::init(LogLevel::Debug, Some("/var/log/vanguards.log")).unwrap();
// Log to syslog
logger::init(LogLevel::Notice, Some(":syslog:")).unwrap();§What This Module Does NOT Do
- Log rotation: Use external tools like logrotate
- Log aggregation: Use external services for centralized logging
- Structured logging: Currently outputs plain text only
§See Also
crate::config::LogLevel- Log level enumerationcrate::logguard- Log buffering for circuit debugging- tracing crate - Underlying logging framework