]>
Commit | Line | Data |
---|---|---|
2c00a5a8 XL |
1 | //! Debug Logging |
2 | //! | |
3 | //! To use in a debug build, set the env var `RAYON_LOG=1`. In a | |
4 | //! release build, logs are compiled out. You will have to change | |
5 | //! `DUMP_LOGS` to be `true`. | |
6 | //! | |
7 | //! **Old environment variable:** `RAYON_LOG` is a one-to-one | |
8 | //! replacement of the now deprecated `RAYON_RS_LOG` environment | |
9 | //! variable, which is still supported for backwards compatibility. | |
10 | ||
e74abb32 | 11 | #[cfg(debug_assertions)] |
2c00a5a8 XL |
12 | use std::env; |
13 | ||
e74abb32 XL |
14 | #[cfg_attr(debug_assertions, derive(Debug))] |
15 | #[cfg_attr(not(debug_assertions), allow(dead_code))] | |
16 | pub(super) enum Event { | |
532ac7d7 XL |
17 | Tickle { |
18 | worker: usize, | |
19 | old_state: usize, | |
20 | }, | |
21 | GetSleepy { | |
22 | worker: usize, | |
23 | state: usize, | |
24 | }, | |
25 | GotSleepy { | |
26 | worker: usize, | |
27 | old_state: usize, | |
28 | new_state: usize, | |
29 | }, | |
30 | GotAwoken { | |
31 | worker: usize, | |
32 | }, | |
33 | FellAsleep { | |
34 | worker: usize, | |
35 | }, | |
36 | GotInterrupted { | |
37 | worker: usize, | |
38 | }, | |
39 | FoundWork { | |
40 | worker: usize, | |
41 | yields: usize, | |
42 | }, | |
43 | DidNotFindWork { | |
44 | worker: usize, | |
45 | yields: usize, | |
46 | }, | |
47 | StoleWork { | |
48 | worker: usize, | |
49 | victim: usize, | |
50 | }, | |
51 | UninjectedWork { | |
52 | worker: usize, | |
53 | }, | |
54 | WaitUntil { | |
55 | worker: usize, | |
56 | }, | |
57 | LatchSet { | |
58 | worker: usize, | |
59 | }, | |
60 | InjectJobs { | |
61 | count: usize, | |
62 | }, | |
63 | Join { | |
64 | worker: usize, | |
65 | }, | |
66 | PoppedJob { | |
67 | worker: usize, | |
68 | }, | |
69 | PoppedRhs { | |
70 | worker: usize, | |
71 | }, | |
72 | LostJob { | |
73 | worker: usize, | |
74 | }, | |
75 | JobCompletedOk { | |
76 | owner_thread: usize, | |
77 | }, | |
78 | JobPanickedErrorStored { | |
79 | owner_thread: usize, | |
80 | }, | |
81 | JobPanickedErrorNotStored { | |
82 | owner_thread: usize, | |
83 | }, | |
84 | ScopeCompletePanicked { | |
85 | owner_thread: usize, | |
86 | }, | |
87 | ScopeCompleteNoPanic { | |
88 | owner_thread: usize, | |
89 | }, | |
2c00a5a8 XL |
90 | } |
91 | ||
e74abb32 | 92 | #[cfg(debug_assertions)] |
6a06907d | 93 | lazy_static::lazy_static! { |
e74abb32 | 94 | pub(super) static ref LOG_ENV: bool = |
532ac7d7 | 95 | env::var("RAYON_LOG").is_ok() || env::var("RAYON_RS_LOG").is_ok(); |
2c00a5a8 XL |
96 | } |
97 | ||
e74abb32 XL |
98 | #[cfg(debug_assertions)] |
99 | macro_rules! log { | |
100 | ($event:expr) => { | |
101 | if *$crate::log::LOG_ENV { | |
102 | eprintln!("{:?}", $event); | |
103 | } | |
104 | }; | |
105 | } | |
106 | ||
107 | #[cfg(not(debug_assertions))] | |
2c00a5a8 XL |
108 | macro_rules! log { |
109 | ($event:expr) => { | |
e74abb32 XL |
110 | if false { |
111 | // Expand `$event` so it still appears used, but without | |
112 | // any of the formatting code to be optimized away. | |
113 | $event; | |
532ac7d7 XL |
114 | } |
115 | }; | |
2c00a5a8 | 116 | } |