pub struct LogfmtFormat { /* private fields */ }Available on crate feature
logfmt only.Expand description
logfmt formatter. See the module docs for the wire format.
User keys named timestamp, level, target, message, file
or line are written as fields.<name>.
§Examples
use log_io::format::{Format, LogfmtFormat};
use log_io::{Field, Level, Metadata, Record};
let fields = [Field::new("port", 8080_u32), Field::new("path", "/a b")];
let record = Record::new(Metadata::new(Level::Info, "app"), "ok", &fields);
let mut out = String::new();
LogfmtFormat::new().write_record(&record, &mut out)?;
assert_eq!(out, "level=info target=app message=ok port=8080 path=\"/a b\"\n");Implementations§
Source§impl LogfmtFormat
impl LogfmtFormat
Sourcepub const fn timestamp_rfc3339(self, enabled: bool) -> Self
pub const fn timestamp_rfc3339(self, enabled: bool) -> Self
Emit timestamps as RFC 3339 (timestamp=2023-11-14T22:13:20.000000000Z)
instead of Unix nanoseconds (the default).
Trait Implementations§
Source§impl Clone for LogfmtFormat
impl Clone for LogfmtFormat
impl Copy for LogfmtFormat
Source§impl Debug for LogfmtFormat
impl Debug for LogfmtFormat
Source§impl Default for LogfmtFormat
impl Default for LogfmtFormat
Source§impl Format for LogfmtFormat
impl Format for LogfmtFormat
Auto Trait Implementations§
impl Freeze for LogfmtFormat
impl RefUnwindSafe for LogfmtFormat
impl Send for LogfmtFormat
impl Sync for LogfmtFormat
impl Unpin for LogfmtFormat
impl UnsafeUnpin for LogfmtFormat
impl UnwindSafe for LogfmtFormat
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