Struct tracing_log::LogTracer [−][src]
A simple “logger” that converts all log records into tracing
Event
s.
Implementations
impl LogTracer
[src]
pub fn builder() -> Builder
[src]
Returns a builder that allows customizing a LogTracer
and setting it
the default logger.
For example:
use tracing_log::LogTracer; use log; LogTracer::builder() .ignore_crate("foo") // suppose the `foo` crate is using `tracing`'s log feature .with_max_level(log::LevelFilter::Info) .init()?; // will be available for Subscribers as a tracing Event log::info!("an example info log");
pub fn new() -> Self
[src]
Creates a new LogTracer
that can then be used as a logger for the log
crate.
It is generally simpler to use the init
or init_with_filter
methods
which will create the LogTracer
and set it as the global logger.
Logger setup without the initialization methods can be done with:
use tracing_log::LogTracer; use log; let logger = LogTracer::new(); log::set_boxed_logger(Box::new(logger))?; log::set_max_level(log::LevelFilter::Trace); // will be available for Subscribers as a tracing Event log::trace!("an example trace log");
pub fn init_with_filter(level: LevelFilter) -> Result<(), SetLoggerError>
[src]
Sets up LogTracer
as global logger for the log
crate,
with the given level as max level filter.
Setting a global logger can only be done once.
The builder
function can be used to customize the LogTracer
before
initializing it.
pub fn init() -> Result<(), SetLoggerError>
[src]
Sets a LogTracer
as the global logger for the log
crate.
Setting a global logger can only be done once.
use tracing_log::LogTracer; use log; LogTracer::init()?; // will be available for Subscribers as a tracing Event log::trace!("an example trace log");
This will forward all logs to tracing
and lets the current Subscriber
determine if they are enabled.
The builder
function can be used to customize the LogTracer
before
initializing it.
If you know in advance you want to filter some log levels,
use builder
or init_with_filter
instead.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for LogTracer
impl Send for LogTracer
impl Sync for LogTracer
impl Unpin for LogTracer
impl UnwindSafe for LogTracer
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,