Crate logcontrol_tracing
source ·Expand description
A LogControl1
implementation for tracing
.
TracingLogControl1
provides a LogControl1
implementation on top of
tracing, which uses the reload layer to
dyanmically switch layers and level filters when the log target or log level
are changed over the log control interfaces.
It uses a LogControl1LayerFactory
implementation to create the log target
layers each time the log target is changed. This crates provides a default
PrettyLogControl1LayerFactory
which uses the pretty format of
tracing_subscriber
on stdout for the console target and
tracing_journald
for the Journal target. You can provide your own
implementation to customize the layer for each target.
When created TracingLogControl1
additionally returns a layer which needs
to be added to the global tracing subscriber, i.e. a tracing_subscriber::Registry
,
for log control to have any effect.
use logcontrol::*;
use logcontrol_tracing::*;
use tracing_subscriber::prelude::*;
let (control, layer) = TracingLogControl1::new_auto(
PrettyLogControl1LayerFactory,
tracing::Level::INFO,
).unwrap();
let subscriber = tracing_subscriber::Registry::default().with(layer);
tracing::subscriber::set_global_default(subscriber).unwrap();
// Then register `control` over DBus, e.g. via `logcontrol_zbus::LogControl1`.
Re-exports
pub use logcontrol;
Structs
- A layer factory which uses pretty printing on stdout for the console target.
- A
LogControl1
implementation fortracing
.
Traits
- A factory to create layers for
TracingLogControl1
.
Functions
- Convert
logcontrol::LogLevel
to [tracing::Level
]. - Whether the current process is directly connected to the systemd journal.
- Determine the syslog identifier for this process.
Type Aliases
- The final type for the layer that implements the log control interface.
- The type of the layer that implements the log target.