pub struct Logger {
pub mode: PRINTMODE,
/* private fields */
}Expand description
this is the tklog encapsulated Logger whose File operations are based on the standard library std::fs::File,therefore, it is a bio sync operation object. Logger allows you to set parameters for log printing of tklog.
§Examples
Create a Logger Object and set the parameters:
use tklog::sync::Logger;
use tklog::Format;
use tklog::LEVEL;
use tklog::MODE;
let mut log = Logger::new();
log.set_console(true)
.set_level(LEVEL::Debug)
.set_format(Format::LevelFlag | Format::Time | Format::ShortFileName)
.set_formatter("{level}{time} {file}:{message}\n")
.set_cutmode_by_size("tklog.log", 1<<20, 0, true);Fields§
§mode: PRINTMODEImplementations§
Source§impl Logger
impl Logger
pub fn new() -> Self
pub fn print(&mut self, level: LEVEL, module: &str, message: &str)
pub fn safeprint(&mut self, level: LEVEL, module: &str, message: &str)
pub fn log(&self, level: LEVEL, module: String, message: String)
pub fn get_level(&mut self, module: &str) -> LEVEL
pub fn is_file_line(&mut self, level: LEVEL, module: &str) -> bool
pub fn fmt( &mut self, module: &str, level: LEVEL, filename: &str, line: u32, message: String, ) -> String
pub fn set_printmode(&mut self, mode: PRINTMODE) -> &mut Self
pub fn set_level(&mut self, level: LEVEL) -> &mut Self
pub fn set_console(&mut self, console: bool) -> &mut Self
Sourcepub fn set_format(&mut self, format: u8) -> &mut Self
pub fn set_format(&mut self, format: u8) -> &mut Self
Format::LevelFlag | Format::Date | Format::Time | Format::ShortFileName;
Sourcepub fn set_formatter(&mut self, formatter: &str) -> &mut Self
pub fn set_formatter(&mut self, formatter: &str) -> &mut Self
default: “{level}{time} {file}:{message}\n”
pub fn set_cutmode_by_size( &mut self, filename: &str, maxsize: u64, maxbackups: u32, compress: bool, ) -> &mut Self
pub fn set_cutmode_by_time( &mut self, filename: &str, mode: MODE, maxbackups: u32, compress: bool, ) -> &mut Self
pub fn set_cutmode_by_mixed( &mut self, filename: &str, maxsize: u64, mode: MODE, maxbackups: u32, compress: bool, ) -> &mut Self
pub fn set_option(&mut self, option: LogOption) -> &mut Self
pub fn set_mod_option(&mut self, module: &str, option: LogOption) -> &mut Self
pub fn set_custom_handler( &mut self, handler: fn(&LogContext) -> bool, ) -> &mut Self
pub fn set_level_option( &mut self, level: LEVEL, option: &dyn OptionTrait, ) -> &mut Self
pub fn set_separator(&mut self, separator: &str) -> &mut Self
pub fn get_separator(&self) -> String
pub fn set_attr_format<F>(&mut self, f: F)
Auto Trait Implementations§
impl !Freeze for Logger
impl !RefUnwindSafe for Logger
impl !UnwindSafe for Logger
impl Send for Logger
impl Sync for Logger
impl Unpin for Logger
impl UnsafeUnpin for Logger
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