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
//! Centralized logging setup for the whole framework.
//!
//! [`init`] installs a global `tracing_subscriber` once at application boot.
//! Everything that emits `tracing` events then flows through it:
//!
//! - **HTTP requests/responses** — `doido-controller`'s middleware stack logs
//! each request and response at `INFO` (via `tower_http`'s `TraceLayer`).
//! - **ORM queries** — `doido-model`'s connection enables sea-orm's SQL logging,
//! which emits `tracing` events.
//! - **Jobs, mail, custom events** — the helpers in [`crate::trace`].
//!
//! The verbosity is controlled by the `RUST_LOG` environment variable
//! (standard `tracing_subscriber` `EnvFilter` syntax); when unset, [`init`] falls
//! back to [`DEFAULT_DIRECTIVES`].
use Once;
use ;
/// Default `EnvFilter` directives when `RUST_LOG` is unset.
///
/// `info` shows app logs and the HTTP request/response events (emitted by
/// `tower_http` at INFO). `sqlx::query=info` surfaces sea-orm's SQL statements
/// (logged by sqlx under that target) while `sqlx=warn` quiets the rest of the
/// connection-pool chatter; `hyper`/`tower` internals are quieted too.
pub const DEFAULT_DIRECTIVES: &str = "info,sqlx=warn,sqlx::query=info,hyper=warn,tower=warn";
static INIT: Once = new;
/// Installs the global tracing subscriber using `RUST_LOG` (or
/// [`DEFAULT_DIRECTIVES`]). Idempotent and safe to call more than once.
/// Like [`init`] but uses `default_directives` when `RUST_LOG` is unset.