pub struct AttrFormat { /* private fields */ }Implementations§
Source§impl AttrFormat
impl AttrFormat
pub fn new() -> AttrFormat
Sourcepub fn set_level_fmt<F>(&mut self, levelfmt: F)
pub fn set_level_fmt<F>(&mut self, levelfmt: F)
§Exmaple
set_level_fmt(|level| {
let s = match level {
LEVEL::Trace => "[T]",
LEVEL::Debug => "[D]",
LEVEL::Info => "[I]",
LEVEL::Warn => "[W]",
LEVEL::Error => "[E]",
LEVEL::Fatal => "[F]",
LEVEL::Off => "",
};
s.to_string()
});Sourcepub fn set_time_fmt<F>(&mut self, timefmt: F)
pub fn set_time_fmt<F>(&mut self, timefmt: F)
- This function splits a date into three parts and returns a tuple (String, String, String).
- You can customize the data for these three parts.
§Generally,
- the first part is the date in the format
%Y-%m-%d, - the second part is the time in the format
%H:%M:%S, - and the third part is the fractional seconds, such as
6f.
§Example
set_time_fmt(|| {
let now: DateTime<Local> = Local::now();
(now.format("%Y-%m-%d").to_string(), now.format("%H:%M:%S").to_string(), ".6f".to_string())
});Sourcepub fn set_body_fmt<F>(&mut self, bodyfmt: F)
pub fn set_body_fmt<F>(&mut self, bodyfmt: F)
§This function will support the reprocessing of log information
§Example
fmt.set_body_fmt(|level,body| {
match level {
LEVEL::Trace => format!("{}{}{}","\x1b[34m" ,body,"\x1b[0m") , //blue
LEVEL::Debug => format!("{}{}{}","\x1b[36m" ,body,"\x1b[0m") , //cyan
LEVEL::Info => format!("{}{}{}","\x1b[32m" ,body,"\x1b[0m") , //green
LEVEL::Warn => format!("{}{}{}","\x1b[33m" ,body,"\x1b[0m") , //yellow
LEVEL::Error => format!("{}{}{}","\x1b[31m" ,body,"\x1b[0m") , //red
LEVEL::Fatal => format!("{}{}{}","\x1b[41m" ,body,"\x1b[0m") , //red-background
LEVEL::Off => "".to_string(),
}
});Auto Trait Implementations§
impl Freeze for AttrFormat
impl !RefUnwindSafe for AttrFormat
impl Send for AttrFormat
impl Sync for AttrFormat
impl Unpin for AttrFormat
impl !UnwindSafe for AttrFormat
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