Struct rust_utils::logging::Log
source · pub struct Log { /* private fields */ }
Expand description
An automatic rotating log based on the current date
It logs output like the following
[hh:mm:ss] [LEVEL]: message
Implementations§
source§impl Log
impl Log
sourcepub fn new(log_name: &str, folder: &str) -> Log
pub fn new(log_name: &str, folder: &str) -> Log
Creates a new log handle
Logs will be stored under $HOME/.local/share/<folder>
and
named <log_name>-<year>-<month>-<day>.log
Panics: You don’t seem to have a home folder. Make sure $HOME is set.
sourcepub fn main_log(self, main_log: bool) -> Log
pub fn main_log(self, main_log: bool) -> Log
If this is true, there will be a main application log under
/tmp/<folder name>-<username>/app.log
This log will be available for viewing until the system is rebooted
sourcepub fn line<T: Display>(&self, level: LogLevel, text: T, print_stdout: bool)
pub fn line<T: Display>(&self, level: LogLevel, text: T, print_stdout: bool)
Print a line to the log
This will print any object that implements Display
sourcepub fn line_basic<T: Display>(&self, text: T, print_stdout: bool)
pub fn line_basic<T: Display>(&self, text: T, print_stdout: bool)
Print a line to the log (basic info)
sourcepub fn report_panics(&self, report: bool)
pub fn report_panics(&self, report: bool)
Should this log handle be used to report application panics? This creates a panic handler that logs the thread panicked, where the panic occurred in the source and the backtrace.
This could be useful in conjunction with libraries that block stdout/stderr like cursive
sourcepub fn main_log_path(&self) -> Option<PathBuf>
pub fn main_log_path(&self) -> Option<PathBuf>
Returns the path of the main log for viewing
Returns None
if the main log is not enabled
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Log
impl RefUnwindSafe for Log
impl Send for Log
impl Sync for Log
impl Unpin for Log
impl UnwindSafe for Log
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
)