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