-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlog.rs
47 lines (39 loc) · 1009 Bytes
/
log.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
// cargo run --example log --features=log-compat
use std::time::Duration;
use duo_subscriber::DuoLayer;
use log::debug;
use tonic::transport::Uri;
use tracing::Level;
use tracing_subscriber::{self, filter::Targets, layer::SubscriberExt, util::SubscriberInitExt};
#[tracing::instrument]
fn foo() {
debug!("hello foo!");
bar();
debug!("called bar!");
}
#[tracing::instrument]
fn bar() {
debug!("hello bar!");
baz();
}
#[tracing::instrument]
fn baz() {
debug!("hello baz!");
}
#[tokio::main]
async fn main() {
let name = "log";
let uri = Uri::from_static("http://127.0.0.1:6000");
let duo_layer = DuoLayer::new(name, uri).await;
tracing_subscriber::registry()
.with(duo_layer)
.with(
Targets::new()
.with_target(name, Level::DEBUG)
.with_target("tracing_subscriber", Level::DEBUG),
)
.init();
debug!("Bootstrap...");
foo();
tokio::time::sleep(Duration::from_secs(1)).await;
}