Struct session_log::Logger
source · pub struct Logger { /* private fields */ }Expand description
Logger is the base type that actually handle the loggings
Implementations§
source§impl Logger
impl Logger
sourcepub fn new<F: Formatter>(name: impl Into<String>, config: Config) -> Self
pub fn new<F: Formatter>(name: impl Into<String>, config: Config) -> Self
Creating a new logger with the given name.
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.