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
//! Tracing-subscriber initialisation shared by both binaries.
//!
//! Both `manta-cli` and `manta-server` call [`configure`] exactly once
//! at startup, after the config file has supplied a `log` directive.
//! Centralising the setup here keeps target filtering, the `log →
//! tracing` bridge, and the timestamp toggle consistent across the two
//! binaries — useful when grepping logs from a CLI invocation that
//! triggered a server-side action.
use EnvFilter;
/// Configure the global tracing subscriber and bridge `log::` calls into it.
///
/// `log_level` is an `EnvFilter` directive string, e.g. `"info"`, `"debug"`,
/// or `"manta=debug,hyper=warn"`. Falls back to `"error"` on parse failure.
///
/// `with_timestamps` controls whether each emitted line is prefixed with
/// the local time. The long-running server enables this so operators can
/// correlate events across requests; the interactive CLI disables it to
/// keep terminal output uncluttered.
///
/// Call this exactly once per process; subsequent calls are no-ops
/// (the subscriber is global and `init()` is idempotent-ish — it
/// panics on a second install, so guard with `OnceCell` if you need
/// to re-configure).
///
/// # Examples
///
/// Typical CLI startup — no timestamps, simple level:
///
/// ```no_run
/// use manta_shared::common::log_ops;
///
/// log_ops::configure("info", false);
/// tracing::info!("manta-cli starting");
/// ```
///
/// Server startup with per-target filtering:
///
/// ```no_run
/// use manta_shared::common::log_ops;
///
/// log_ops::configure("manta=debug,hyper=warn,tower_http=info", true);
/// ```