Struct session_log::Global
source · pub struct Global(/* private fields */);Expand description
The Global logger will share the same logger instance across the entire program that has the same
name. This is useful when the logger is configured once and used in multiple places. The logger
will be created with default configurations if it does not exist.
Implementations§
source§impl Global
impl Global
sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Get a logger with the given name. If the logger does not exist, a new logger will be created and registered with the given name & default configurations.
sourcepub fn register<F: Formatter>(name: &str, config: Config) -> Self
pub fn register<F: Formatter>(name: &str, config: Config) -> Self
Register a logger with the given name.
sourcepub fn unregister(name: &str)
pub fn unregister(name: &str)
Unregister a logger with the given name. Logger will be dropped if no other reference exists.
sourcepub fn session(name: &str, session: &str, silent: bool) -> Session
pub fn session(name: &str, session: &str, silent: bool) -> Session
Create a session from the global logger without constructing a new logger first.
sourcepub fn session_then<F, T>(&self, name: &str, silent: bool, callable: F) -> T
pub fn session_then<F, T>(&self, name: &str, silent: bool, callable: F) -> T
Create a new session from the session and execute the callable with the session passed in.
This can be handy for isolating the environment of each callable while also providing a common logging interface for any callable that needs to be logged.
Methods from Deref<Target = Logger>§
sourcepub fn session(&self, name: &str, silent: bool) -> Session
pub fn session(&self, name: &str, silent: bool) -> Session
Create a new session from the logger.
There are two types of session: silent & non-silent. Silent session will not print the header and footer of the session when no message is logged before the session is dropped. It’s useful session that may potentially not log anything. Non-silent session will always print the header and footer of the session.
Due to the uncertainty of if the session will log anything, the header will be deferred until the first log. If the session logged anything, it’ll act like a non-silent session.
sourcepub fn session_then<F, T>(&self, name: &str, silent: bool, callable: F) -> T
pub fn session_then<F, T>(&self, name: &str, silent: bool, callable: F) -> T
Create a new session from the session and execute the callable with the session passed in.
This can be handy for isolating the environment of each callable while also providing a common logging interface for any callable that needs to be logged.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Global
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnwindSafe for Global
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)