pub struct TracingLogControl1<F, S>{ /* private fields */ }
Expand description
A LogControl1
implementation for tracing
.
This implementation creates a tracing layer which combines two reloadable layers, on for the log target, and another one for the level filter implementing the desired log level. It keeps the reload handles internally and reloads newly created layers whenever the target or the level is changed.
Currently, this implementation only supports the following KnownLogTarget
s:
Any other target fails with LogControl1Error::UnsupportedLogTarget
.
Implementations§
Source§impl<F, S> TracingLogControl1<F, S>
impl<F, S> TracingLogControl1<F, S>
Sourcepub fn new(
factory: F,
connected_to_journal: bool,
syslog_identifier: String,
target: KnownLogTarget,
level: Level,
) -> Result<(Self, LogControl1Layer<F, S>), LogControl1Error>
pub fn new( factory: F, connected_to_journal: bool, syslog_identifier: String, target: KnownLogTarget, level: Level, ) -> Result<(Self, LogControl1Layer<F, S>), LogControl1Error>
Create a new layer controlled through the log interface.
factory
creates the tracing_subscriber::Layer
for the selected target
which denotes the initial log target. The factory
is invoked whenever the
log target is changed, to create a new layer to use for the selected log
target. See TracingLogControl1
for supported target
s.
connected_to_journal
indicates whether this process is connected to the systemd
journal. Set to true
to make KnownLogTarget::Auto
use KnownLogTarget::Journal
,
otherwise it uses KnownLogTarget::Console
.
level
denotes the default tracing log level to start with.
syslog_identifier
is passed to LogControl1LayerFactory::create_journal_layer
for use as SYSLOG_IDENTIFIER
journal field.
§Errors
Return an error if target
is not supported, of if creating a layer fails,
e.g. when selecting KnownLogTarget::Journal
on a system where journald is
not running, or inside a container which has no direct access to the journald
socket.
Sourcepub fn new_auto(
factory: F,
level: Level,
) -> Result<(Self, LogControl1Layer<F, S>), LogControl1Error>
pub fn new_auto( factory: F, level: Level, ) -> Result<(Self, LogControl1Layer<F, S>), LogControl1Error>
Create a new layer controlled through the log interface, with automatic defaults.
Use logcontrol::syslog_identifier()
as the syslog identifier, and
determine the initial log target automatically according to
logcontrol::stderr_connected_to_journal()
.
level
denotes the initial level; see Self::new
for factory
.
§Errors
See Self::new
.