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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// SPDX-FileCopyrightText: (c) 2026 Joel Winarske
// SPDX-License-Identifier: MIT
//! The `log_*!` entry points.
//!
//! Each macro checks the active level *before* touching its arguments, so a
//! record below the threshold costs one relaxed atomic load and a branch —
//! the formatting arguments are never evaluated. This mirrors the C++
//! templates, which pay formatting cost only when the level admits the record.
/// Emit at [`LogLevel::Error`](crate::LogLevel::Error).
/// Emit at [`LogLevel::Warn`](crate::LogLevel::Warn).
/// Emit at [`LogLevel::Info`](crate::LogLevel::Info).
/// Emit at [`LogLevel::Debug`](crate::LogLevel::Debug).
/// Emit a line belonging to an opt-in diagnostic channel — one already gated
/// by its own switch, such as the `DRM_ALLOC_DEBUG` / `DRM_EXT_DMABUF_DEBUG`
/// environment variables on the C++ side.
///
/// **Deliberately bypasses the global level**: the channel's own gate *is* its
/// threshold. This mirrors `GStreamer`, where `GST_DEBUG=cat:5` raises a named
/// category above the default threshold — asking for a category by name is not
/// vetoed by the default. Routing the other way would mean `DRM_ALLOC_DEBUG=1`
/// printed nothing at the default `Info` level, which reads as the switch
/// being broken.
///
/// What it does *not* bypass is the sink: channel output goes wherever
/// [`set_log_sink`](crate::set_log_sink) points, so it survives on targets
/// whose stderr goes nowhere.
///
/// Callers must check their own gate first — this pays full formatting cost
/// unconditionally.
///
/// ```
/// use drmkit_log::{LogLevel, log_channel};
///
/// if std::env::var_os("DRM_ALLOC_DEBUG").is_some() {
/// log_channel!(LogLevel::Debug, "layer {} -> plane {}", 0, 31);
/// }
/// // Reaches the sink even at Silent -- the channel's own gate is its
/// // threshold. Pinned by `channel_bypasses_level_but_not_sink`; not asserted
/// // here because the level and sink are process-global.
/// log_channel!(LogLevel::Debug, "always reaches the sink");
/// ```
/// Shared body of the four level macros. Not public API.