-
|
I am trying to follow this example: When I run this example by cloning the repo and then running The logs become events etc. But when I try similar code in my codebase logforth::starter_log::builder()
.dispatch(|d| d.filter(LevelFilter::All)
.append(append::FastraceEvent::default()))
.dispatch(|d| d.filter(make_log_filter())
.diagnostic(diagnostic::FastraceDiagnostic::default())
.append(logforth::append::Stdout::default()))
.apply();
fastrace::set_reporter(ConsoleReporter, Config::default());
let trace_id = opt.trace_id.as_ref()
.and_then(|trace_id| TraceId::from_str(&trace_id)
.inspect_err(|err| eprintln!("{err}")).ok());
let span_context = if let Some(trace_id) = trace_id {
SpanContext::new(trace_id, SpanId(0))
} else {
SpanContext::random()
};
let root = Span::root("root", span_context);
let _g = root.set_local_parent();
log::info!("Starting program");
...
fastrace::flush();The logs look like this: And here's another difference: in the example I can remove the following code and still get structured logs: But in my program, removing that code leads me to not getting any logs at all. Do I need to configure environment variables or something else to get similar results as in the example? This is how I have added fastrace = { version = "0.7.16", features = ["enable"] }
logforth = { version = "0.29.1", features = ["append-fastrace", "diagnostic-fastrace", "starter-log"] }
log = "0.4.29" |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Okay, I think I got it. |
Beta Was this translation helpful? Give feedback.
Okay, I think I got it.
rootand/or_ghad not gone out of scope beforefastrace::flush().