pub struct Pretty;forest only.Expand description
Format logs for pretty printing.
§Interpreting span times
Spans have the following format:
<NAME> [ <DURATION> | <BODY> / <ROOT> ]- DURATION represents elapsed time while the span has at least one active entry.
Overlapping entries into the same span count once. If the span instruments a
Future, time between polls does not count because the span is not entered then. - BODY represents the percent time the span is entered relative to the root span, excluding time that any child spans are entered.
- ROOT represents the percent time the span is entered relative to the root span, including time that any child spans are entered.
As a mental model, look at ROOT to quickly narrow down which branches are
costly, and look at BODY to pinpoint exactly which spans are expensive.
Spans without any child spans would have the same BODY and ROOT, so the
redundancy is omitted.
Durations accumulate child work: overlapping children contribute separately,
and a parent’s total is raised to at least their sum. Totals can therefore
exceed wall-clock time; see Span::total_duration.
A root with zero duration displays 0.00% for all percentages.
With forest-cpu-time, an additional [ user: <TIME> | sys: <TIME> ] shows
inclusive user and kernel CPU time. This is omitted on unsupported platforms
or when measurements are incomplete. CPU times exclude blocked time and
include parallel children; elapsed-time percentages are unchanged.
Use Pretty::with_max_level to omit less important nodes from the output
while retaining their more important descendants and the original durations.
§Examples
An arbitrarily complex example:
INFO try_from_entry_ro [ 324µs | 8.47% / 100.00% ]
INFO ┝━ server::internal_search [ 296µs | 19.02% / 91.53% ]
INFO │ ┝━ i [filter.info]: Some filter info...
INFO │ ┝━ server::search [ 226µs | 10.11% / 70.01% ]
INFO │ │ ┝━ be::search [ 181µs | 6.94% / 55.85% ]
INFO │ │ │ ┕━ be::search -> filter2idl [ 158µs | 19.65% / 48.91% ]
INFO │ │ │ ┝━ be::idl_arc_sqlite::get_idl [ 20.4µs | 6.30% ]
INFO │ │ │ │ ┕━ i [filter.info]: Some filter info...
INFO │ │ │ ┕━ be::idl_arc_sqlite::get_idl [ 74.3µs | 22.96% ]
ERROR │ │ │ ┝━ 🚨 [admin.error]: On no, an admin error occurred :(
DEBUG │ │ │ ┝━ 🐛 [debug]: An untagged debug log
INFO │ │ │ ┕━ i [admin.info]: there's been a big mistake | alive: false | status: "very sad"
INFO │ │ ┕━ be::idl_arc_sqlite::get_identry [ 13.1µs | 4.04% ]
ERROR │ │ ┝━ 🔐 [security.critical]: A security critical log
INFO │ │ ┕━ 🔓 [security.access]: A security access log
INFO │ ┕━ server::search<filter_resolve> [ 8.08µs | 2.50% ]
WARN │ ┕━ 🚧 [filter.warn]: Some filter warning
TRACE ┕━ 📍 [trace]: Finished!Implementations§
Source§impl Pretty
impl Pretty
Sourcepub const fn with_max_level(self, max_level: LevelFilter) -> FilteredPretty
pub const fn with_max_level(self, max_level: LevelFilter) -> FilteredPretty
Select the most verbose level to include in formatted output.
For example, LevelFilter::WARN retains warnings and errors. Visible
descendants of omitted spans are promoted without changing their order or
the durations used for percentages. LevelFilter::OFF produces an empty
string, and LevelFilter::TRACE produces the same output as Pretty.
This filters formatting only; the collected tree is unchanged.
use gix_trace::forest::{Printer, printer::Pretty};
use tracing::metadata::LevelFilter;
let printer = Printer::new().formatter(Pretty.with_max_level(LevelFilter::WARN));