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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//! Turning `-v` into somewhere for the library's events to go.
//!
//! Split from `main.rs` the way `interrupt.rs` and `park.rs` were: that
//! file parses what the operator typed, and deciding what a verbosity count
//! means is a separate question with its own answer to defend.
//!
//! The library emits [`tracing`] events and installs no subscriber, which
//! leaves exactly one place in this workspace allowed to choose where they
//! go. This is it. Everything below is about two risks that pull against
//! each other: a `-v` that says nothing useful, and a `-v` that buries what
//! is useful under somebody else's internals.
use FromStr as _;
use ;
use SubscriberExt as _;
use SubscriberInitExt as _;
/// Every event this workspace emits arrives under this one target.
///
/// One entry covers the library *and* this binary, which looks like a bug
/// and is not: the `[[bin]]` target here is named `modelpipe`, so `rustc`
/// compiles it with that crate name and `module_path!()` — which is what a
/// `tracing` target defaults to — says `modelpipe` for both. A second
/// `modelpipe_cli` entry would match nothing at all.
const OURS: &str = "modelpipe";
/// The transport, which is the only dependency worth naming.
///
/// It is also the loudest. iroh, and the hickory/h2/rustls stack under it,
/// instrument themselves thoroughly and at levels that assume somebody is
/// debugging *them* — so the default for this one is off, and turning it on
/// is a deliberate second and third `-v`.
const TRANSPORT: &str = "iroh";
/// What a verbosity count means.
///
/// Pure and separate from [`install`] so it can be tested, which is the same
/// reason `token_policy` in `main.rs` is a function: the interesting claim
/// is about the mapping, and checking it should not need a process or a
/// global subscriber.
///
/// The shape of the ladder is the argument. Level 0 is not silence — a
/// stream that fails mid-exchange is a real event with nobody else to
/// report it, and an operator who never passed a flag should still hear
/// about it. Level 1 is the access log: one line per request, one per peer
/// arriving and leaving, and nothing from the transport. Only at 2 does
/// anything below this workspace get a say, because the first question
/// `-vv` is asked is "why will it not pair", and that answer lives in iroh.
///
/// There is deliberately no level that turns the whole dependency graph to
/// `trace`. It is not a verbosity, it is a firehose — hickory and rustls at
/// `trace` produce thousands of lines before the first request — and
/// `RUST_LOG` is the escape hatch for anyone who genuinely wants it.
pub
/// Whether a line names the target it came from.
///
/// Pure and separate for the same reason [`targets`] is: it is a decision
/// with an argument behind it, and the argument is checkable without a
/// process or a global subscriber.
///
/// The column is worth its width only when more than one target can appear.
/// That is the second `-v` — and *any* `RUST_LOG`, which is the case that
/// makes this a function rather than a comparison. `RUST_LOG` replaces the
/// ladder wholesale, and `Targets` accepts a bare level, so the ordinary
/// `RUST_LOG=debug` admits the entire dependency graph. Keying the column
/// off the `-v` count alone hid it in precisely the configuration with the
/// most targets to tell apart.
pub const
/// Install the subscriber for this run.
///
/// **stderr, not stdout**, and that is load-bearing rather than
/// conventional. `serve` prints the ticket and the token on stdout so they
/// can be piped somewhere; `modelpipe serve … | head -1` is a thing people
/// do, and a diagnostic on that stream corrupts the one output this program
/// has that another program reads. The same rule the ephemeral-identity
/// note in `main.rs` already follows, for the same reason.
///
/// `RUST_LOG` replaces the computed filter rather than adding to it: half a
/// filter from a flag and half from the environment is a filter nobody can
/// predict from either. A value that does not parse is reported and then
/// ignored — a typo in an environment variable should not stop a tunnel
/// coming up.
pub