pub struct LogFilterKV { /* private fields */ }Expand description
LogFilter that carries one additional value into log format
Example with a key as “req_id”:
use captains_log::*;
fn debug_format_req_id_f(r: FormatRecord) -> String {
let time = r.time();
let level = r.level();
let file = r.file();
let line = r.line();
let msg = r.msg();
let req_id = r.key("req_id");
format!("[{time}][{level}][{file}:{line}] {msg}{req_id}\n").to_string()
}
let mut builder = recipe::file_logger_custom("/tmp", "log_filter", log::Level::Debug,
recipe::DEFAULT_TIME, debug_format_req_id_f);
builder.dynamic = true;
builder.build().expect("setup_log");
let logger = LogFilterKV::new("req_id", format!("{:016x}", 123).to_string());
logger_debug!(logger, "captain's log");Implementations§
Trait Implementations§
Source§impl Clone for LogFilterKV
impl Clone for LogFilterKV
Source§fn clone(&self) -> LogFilterKV
fn clone(&self) -> LogFilterKV
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !Freeze for LogFilterKV
impl RefUnwindSafe for LogFilterKV
impl Send for LogFilterKV
impl Sync for LogFilterKV
impl Unpin for LogFilterKV
impl UnwindSafe for LogFilterKV
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