1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! # Logger initialization and configuration.
//!
//! This module contains the backend logger.
//!
//! See [`init_logger`] for the entry point.
pub use LoggerConfig;
pub use LoggerError;
pub use LoggerFormat;
pub use LoggerLevel;
pub use ;
pub use timezone_sync;
/// Initializes the global tracing subscriber based on the given [`LoggerConfig`].
///
/// Dispatches to the appropriate backend based on [`LoggerConfig::format`]:
///
/// | Format | Backend | Notes |
/// |---------------------------|---------------------------------|------------------------------|
/// | [`LoggerFormat::Text`] | `tracing_subscriber::fmt` | Colored, human-readable |
/// | [`LoggerFormat::Json`] | `tracing_subscriber::fmt::json` | Structured, machine-readable |
/// | [`LoggerFormat::Journald`]| `tracing_journald` | Linux only |
///
/// Once initialized, all `tracing` macros (`info!`, `debug!`, etc.) will use this configuration.
/// Can only be called **once** per process - subsequent calls return [`LoggerError::AlreadyInitialized`].
///
/// ## Local timezone
///
/// When using [`LoggerTimeZone::Local`], call [`init_local_offset`] in `main()` **before** spawning the tokio runtime.
/// See the [crate-level docs](crate#local-timezone-support) for details.
///
/// ## Examples
///
/// ```rust
/// use solti_observe::{LoggerConfig, init_logger};
///
/// let config = LoggerConfig::default();
/// init_logger(&config).expect("Failed to initialize logger");
///
/// tracing::info!("Logger initialized successfully");
/// ```