Skip to content

Commit 7ab29e7

Browse files
author
Corentin Henry
committed
tracing-journald: update example with custom priority mappings
1 parent c2d81c9 commit 7ab29e7

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

examples/examples/journald.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![deny(rust_2018_idioms)]
22
use tracing::{error, info};
3+
use tracing_journald::{Priority, PriorityMappings};
34
use tracing_subscriber::prelude::*;
45

56
#[path = "fmt/yak_shave.rs"]
@@ -10,7 +11,17 @@ fn main() {
1011
.with(tracing_subscriber::fmt::subscriber().with_target(false));
1112
match tracing_journald::subscriber() {
1213
Ok(subscriber) => {
13-
registry.with(subscriber).init();
14+
registry
15+
.with(
16+
subscriber
17+
// We can tweak the mappings between the trace level and
18+
// the journal priorities.
19+
.with_priority_mappings(PriorityMappings {
20+
info: Priority::Informational,
21+
..PriorityMappings::new()
22+
}),
23+
)
24+
.init();
1425
}
1526
// journald is typically available on Linux systems, but nowhere else. Portable software
1627
// should handle its absence gracefully.

0 commit comments

Comments
 (0)