Implement structured logging with tracing, dual output, and fail2ban-compatible format

- Add logging::init() with dual output (file + stdout) via tracing-subscriber Layer composition
- Support configurable log level via LoggingConfig.level and JSON/text format via LoggingConfig.format
- Create log file and parent directories when log_file_path is configured
- Add KvVisitor for custom key=value event field formatting
- Add log_request!, log_rate_limit!, log_upstream_error!, log_config_reload! macros
  with REQUEST, RATE_LIMIT, UPSTREAM_ERROR, CONFIG_RELOAD prefixes
- Add format_event_fields() for extracting structured fields from tracing events
- Add tracing-subscriber env-filter and json features to Cargo.toml
- Add unit tests for KvVisitor formatting, log macros, and init function
- Apply cargo fmt to existing tls/config.rs tests
This commit is contained in:
2026-06-11 12:47:19 +00:00
parent 468adb21de
commit 36319db10e
5 changed files with 400 additions and 11 deletions

View File

@@ -24,7 +24,7 @@ serde = { version = "=1.0.228", features = ["derive"] }
toml = "=0.8.23"
arc-swap = "=1.7.1"
tracing = "=0.1.41"
tracing-subscriber = "=0.3.19"
tracing-subscriber = { version = "=0.3.19", features = ["env-filter", "json"] }
rustls-pemfile = "=2.2.0"
rustls-pki-types = "=1.12.0"
clap = { version = "=4.6.1", features = ["derive"] }