pub struct LoggerBuilder { /* private fields */ }
Expand description
A builder for configuring log dispatching and setting up the global logger.
§Examples
use logforth_core::append;
logforth_core::builder()
.dispatch(|d| d.append(append::Stdout::default()))
.apply();
Implementations§
Source§impl LoggerBuilder
impl LoggerBuilder
Sourcepub fn dispatch<F>(self, f: F) -> Self
pub fn dispatch<F>(self, f: F) -> Self
Register a new dispatch with the LoggerBuilder
.
§Examples
use logforth_core::append;
logforth_core::builder()
.dispatch(|d| d.append(append::Stderr::default()))
.apply();
Sourcepub fn try_apply(self) -> Result<(), Logger>
pub fn try_apply(self) -> Result<(), Logger>
Set up the global logger with all the configured dispatches.
This should be called early in the execution of a Rust program. Any log events that occur before initialization will be ignored.
§Errors
Return an error if a global logger has already been set.
§Examples
if logforth_core::builder().try_apply().is_err() {
eprintln!("failed to set logger");
}
Sourcepub fn apply(self)
pub fn apply(self)
Set up the global logger with all the configured dispatches.
This should be called early in the execution of a Rust program. Any log events that occur before initialization will be ignored.
This function will panic if it is called more than once, or if another library has already initialized a global logger.
§Panics
Panic if the global logger has already been set.
§Examples
logforth_core::builder().apply();
Trait Implementations§
Auto Trait Implementations§
impl Freeze for LoggerBuilder
impl !RefUnwindSafe for LoggerBuilder
impl Send for LoggerBuilder
impl Sync for LoggerBuilder
impl Unpin for LoggerBuilder
impl !UnwindSafe for LoggerBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more