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
pub use chrome::*;
pub use fmt_layer::*;
use std::path::Path;
use tracing_subscriber::{layer::SubscriberExt as _, EnvFilter};
mod chrome;
mod fmt_layer;
pub fn initialize_default_subscriber(chrome_trace_path: Option<&Path>) {
let chrome_tracing_layer_opt =
chrome_trace_path.map(|path| ChromeTracingLayer::with_file(path).unwrap());
if let Some(chrome_tracing_layer) = chrome_tracing_layer_opt {
tracing::subscriber::set_global_default(
tracing_subscriber::Registry::default()
.with(chrome_tracing_layer)
.with(FmtLayer::new())
.with(EnvFilter::from_default_env()),
)
.unwrap();
} else {
tracing::subscriber::set_global_default(
tracing_subscriber::Registry::default()
.with(FmtLayer::new())
.with(EnvFilter::from_default_env()),
)
.unwrap();
}
tracing_log::LogTracer::init().unwrap();
}
thread_local! {
static CURRENT_THREAD_ID: usize = thread_id::get();
}