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
// Copyright Two Neutron Stars Incorporated and contributors
// SPDX-License-Identifier: BlueOak-1.0.0
//! Lightweight stderr logging for IPC connection setup, gated behind a runtime
//! flag the implementing language controls.
//!
//! IPC connection setup (the version handshake in particular) is otherwise
//! invisible: the daemon runs in a separate process with its stderr redirected
//! to `/dev/null`, and a rejected handshake closes the socket before any reply,
//! so clients only ever observe a bare EOF. This module lets both sides narrate
//! that exchange.
//!
//! laburnum deliberately does not know how verbosity is configured — there is
//! no laburnum-specific env var, because that would never match the embedding
//! application's name. Instead the implementing language decides (its own
//! `--verbose` flag, its own `<LANG>_VERBOSE` env var, etc.) and pushes the
//! result in via [`set_enabled`]. The application is also responsible for
//! propagating verbosity to a spawned daemon process (e.g. by setting its own
//! env var, which the daemon inherits and re-applies on startup).
use ;
static ENABLED: AtomicBool = new;
/// Enable or disable verbose IPC logging for this process.
///
/// Called by the embedding application once it has determined verbosity from
/// its own flag/env. Safe to call multiple times; the last call wins.
/// Returns `true` when verbose IPC logging has been enabled via [`set_enabled`].
/// Emit a verbose log line to stderr, but only when [`is_enabled`] is `true`.