1use tracing::{error, info, instrument, warn};
8use tracing_subscriber::prelude::*;
9use tracing_systemd::SystemdLayer;
10
11fn main() {
12 let stdout_layer = SystemdLayer::stdout()
14 .with_target(true)
15 .with_level_prefix(false);
16
17 let journald_layer = tracing_systemd::journald::layer_with_identifier("combined-example").ok();
19
20 tracing_subscriber::registry()
21 .with(stdout_layer)
22 .with(journald_layer)
23 .init();
24
25 work(42);
26}
27
28#[instrument]
29fn work(seed: u64) {
30 info!("starting work");
31 if seed % 2 == 0 {
32 warn!(seed, "even seed — heuristic only");
33 } else {
34 error!(seed, "odd seed — would have failed");
35 }
36}