-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathpretty.rs
More file actions
31 lines (28 loc) · 837 Bytes
/
pretty.rs
File metadata and controls
31 lines (28 loc) · 837 Bytes
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
use owo_colors::OwoColorize;
use tracing::{Event, Subscriber};
use tracing_subscriber::{
fmt::{FmtContext, FormatEvent, FormatFields, format::Writer},
registry::LookupSpan,
};
pub struct PrettyTarget;
impl<S, N> FormatEvent<S, N> for PrettyTarget
where
S: Subscriber + for<'a> LookupSpan<'a>,
N: for<'a> FormatFields<'a> + 'static,
{
// Required method
fn format_event(
&self,
ctx: &FmtContext<'_, S, N>,
mut writer: Writer<'_>,
event: &Event<'_>,
) -> std::fmt::Result {
if writer.has_ansi_escapes() {
write!(&mut writer, "{} ", event.metadata().target().green().bold())?;
} else {
write!(&mut writer, "{} ", event.metadata().target())?;
}
ctx.format_fields(writer.by_ref(), event)?;
writeln!(writer)
}
}