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
// No console window in a release build. Without this, launching the `.exe` directly
// (from Explorer, a shortcut, or the Start menu) opens an empty console alongside the
// window, because Rust binaries default to the Windows CONSOLE subsystem.
//
// `not(debug_assertions)` rather than unconditional: a debug build keeps its console so
// `cargo run` still shows panics and any `tracing` output during development. Note that
// this crate installs no `tracing` subscriber at all today, so a release build currently
// discards nothing by hiding the console -- but if one is ever added here, it must write
// somewhere other than stdout (a file, or the Windows event log) to survive this.
//
// A no-op on every non-Windows target: the attribute is Windows-specific and simply
// ignored elsewhere.
/// Writes panics to a file, because in a release build there is nowhere else for them
/// to go.
///
/// `windows_subsystem = "windows"` above means a release build has no console, and this
/// crate installs no `tracing` subscriber -- so a panic on a BACKGROUND thread (the
/// render thread, an export worker, a batch lane, a remote-connection thread) currently
/// produces no output whatsoever. The visible result is an app that keeps responding to
/// the window manager while some part of it has silently stopped, which is
/// indistinguishable from a hang and effectively undiagnosable from a bug report.
///
/// Chains to the previous hook rather than replacing it, so a debug build still prints
/// to the console it kept.
///
/// Failing to write the log is deliberately ignored: a panic handler that panics (or
/// that refuses to let the default handler run because a directory was read-only) would
/// be strictly worse than the silence it is here to fix.