Some checks failed
CI Pipeline / Rust Format Check (push) Failing after 2s
CI Pipeline / Clippy Lints (push) Failing after 1s
CI Pipeline / Rust Unit Tests (push) Failing after 2s
CI Pipeline / Security Audit (push) Failing after 2s
CI Pipeline / Frontend Lint & Type Check (push) Failing after 3s
CI Pipeline / Build .deb & Release (push) Has been skipped
- health_poller: persist agent_version from HealthData.version - health_poller: call /system/info to update os_family, os_name, arch - enrollment: set os_family and arch from os_details during approval - enrollment: build os_name from os+os_version when name field absent - COALESCE in UPDATE preserves existing values when new data unavailable - version bump 0.1.7 -> 0.1.8
32 lines
1.1 KiB
Rust
Executable File
32 lines
1.1 KiB
Rust
Executable File
use crate::config::LoggingConfig;
|
|
use tracing_subscriber::{fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter};
|
|
|
|
/// Initialize the global tracing subscriber.
|
|
///
|
|
/// Format is controlled by `cfg.format`:
|
|
/// - `"json"` — machine-readable JSON (production default)
|
|
/// - anything else — human-readable pretty output (development)
|
|
///
|
|
/// Log level is controlled by `cfg.level` (e.g. `"info"`, `"debug"`).
|
|
/// The `RUST_LOG` environment variable overrides `cfg.level`.
|
|
pub fn init(cfg: &LoggingConfig) {
|
|
let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new(&cfg.level));
|
|
|
|
match cfg.format.as_str() {
|
|
"json" => {
|
|
tracing_subscriber::registry()
|
|
.with(filter)
|
|
.with(fmt::layer().json().with_current_span(true))
|
|
.init();
|
|
},
|
|
_ => {
|
|
tracing_subscriber::registry()
|
|
.with(filter)
|
|
.with(fmt::layer().pretty())
|
|
.init();
|
|
},
|
|
}
|
|
|
|
tracing::info!(format = %cfg.format, level = %cfg.level, "Logging initialized");
|
|
}
|