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§
- Pretty
LogControl1 Layer Factory - A layer factory which uses pretty printing on stdout for the console target.
- Tracing
LogControl1 - A
LogControl1implementation fortracing.
Traits§
- LogControl1
Layer Factory - A factory to create layers for
TracingLogControl1.
Functions§
- from_
log_ level - Convert
logcontrol::LogLeveltotracing::Level. - stderr_
connected_ to_ journal - Whether the current process is directly connected to the systemd journal.
- syslog_
identifier - Determine the syslog identifier for this process.
Type Aliases§
- LogControl1
Layer - The final type for the layer that implements the log control interface.
- LogTarget
Layer - The type of the layer that implements the log target.