-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.rs
52 lines (45 loc) · 1.11 KB
/
main.rs
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
use std::time::Duration;
use duo_subscriber::DuoLayer;
use tonic::transport::Uri;
use tracing::{debug, error, info, warn, Level};
use tracing_subscriber::{
self, filter::Targets, fmt, layer::SubscriberExt, util::SubscriberInitExt,
};
#[tracing::instrument]
fn foo() {
info!(test = true, "hello foo!");
bar();
debug!("called bar!");
foz();
}
#[tracing::instrument]
fn bar() {
baz();
}
#[tracing::instrument]
fn baz() {
warn!("hello baz!");
}
#[tracing::instrument]
fn foz() {
debug!("hello foz!");
error!(flag = 1, data = "data", "Oops!");
}
#[tokio::main]
async fn main() {
let fmt_layer = fmt::layer();
let uri = Uri::from_static("http://127.0.0.1:6000");
let duo_layer = DuoLayer::new("example", uri).await;
tracing_subscriber::registry()
.with(fmt_layer)
.with(duo_layer)
.with(
Targets::new()
.with_target("main", Level::DEBUG)
.with_target("tracing_subscriber", Level::DEBUG),
)
.init();
tracing::info!("Bootstrap...");
foo();
tokio::time::sleep(Duration::from_secs(1)).await;
}