Struct session_log::Session
source · pub struct Session { /* private fields */ }Expand description
Sessions are a way to group log messages together. They are useful for tracking the flow of a program. They can be nested, and when a session is dropped, it will dump all of its messages to the file at once. Despite the file being written to at once, the messages are still written in the traditional order on the terminal. It can also be used as a simple profiling tool, as it will track the starting time of the session and the elapsed time when it is dropped.
§Example
use session_log::{Logger, Loggable};
fn main() {
let logger = Logger::new("main");
foo(logger.session("foo"), 10);
bar(logger.session("bar"), 10);
}
fn foo(logger: impl Loggable, n: usize) {
for i in 0..n {
logger.info(&format!("message-{}", i));
}
}
fn bar(logger: impl Loggable, n: usize) {
for i in 0..n {
logger.warning(&format!("message-{}", i));
}
}Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Session
impl RefUnwindSafe for Session
impl Send for Session
impl Sync for Session
impl Unpin for Session
impl UnwindSafe for Session
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