Struct TracingLogControl1

Source
pub struct TracingLogControl1<F, S>
where F: LogControl1LayerFactory, S: Subscriber + for<'span> LookupSpan<'span>,
{ /* 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 KnownLogTargets:

Any other target fails with LogControl1Error::UnsupportedLogTarget.

Implementations§

Source§

impl<F, S> TracingLogControl1<F, S>
where F: LogControl1LayerFactory, S: Subscriber + for<'span> LookupSpan<'span>,

Source

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 targets.

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.

Source

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.

Trait Implementations§

Source§

impl<F, S> LogControl1 for TracingLogControl1<F, S>
where F: LogControl1LayerFactory, S: Subscriber + for<'span> LookupSpan<'span>,

Source§

fn level(&self) -> LogLevel

Get the currently configured log level.
Source§

fn set_level(&mut self, level: LogLevel) -> Result<(), LogControl1Error>

Set the level of the underlying log framework. Read more
Source§

fn target(&self) -> &str

Get the currently configured log target.
Source§

fn set_target<T: AsRef<str>>( &mut self, target: T, ) -> Result<(), LogControl1Error>

Set the target of the underlying log framework. Read more
Source§

fn syslog_identifier(&self) -> &str

Get the syslog identifier.

Auto Trait Implementations§

§

impl<F, S> Freeze for TracingLogControl1<F, S>
where F: Freeze,

§

impl<F, S> RefUnwindSafe for TracingLogControl1<F, S>
where F: RefUnwindSafe,

§

impl<F, S> Send for TracingLogControl1<F, S>

§

impl<F, S> Sync for TracingLogControl1<F, S>

§

impl<F, S> Unpin for TracingLogControl1<F, S>
where F: Unpin,

§

impl<F, S> UnwindSafe for TracingLogControl1<F, S>
where F: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more