pub struct Metadata<'a> {
pub level: Level,
pub target: &'a str,
pub file: Option<&'a str>,
pub line: Option<u32>,
pub timestamp_unix_nanos: Option<u128>,
}Expand description
Metadata describing the origin and severity of a record.
Most metadata is optional. level and target are required; the
rest is best-effort context that a caller may supply. Macros
populate file and line automatically.
Fields§
§level: LevelSeverity of the record.
target: &'a strLogical target. Typically the module path, but callers are free to use a domain-specific identifier for filtering.
file: Option<&'a str>Source file path, if known.
line: Option<u32>Source line number, if known.
timestamp_unix_nanos: Option<u128>Unix nanoseconds since the epoch. Populated by the logger when
std is available. None indicates the consumer should supply
its own clock (typical in no_std builds).
Implementations§
Source§impl<'a> Metadata<'a>
impl<'a> Metadata<'a>
Sourcepub const fn new(level: Level, target: &'a str) -> Self
pub const fn new(level: Level, target: &'a str) -> Self
Build minimal metadata containing only level and target.
All optional fields are None. Useful for handcrafted records
where a richer context isn’t needed.
Sourcepub const fn with_location(self, file: &'a str, line: u32) -> Self
pub const fn with_location(self, file: &'a str, line: u32) -> Self
Replace the source location.
Sourcepub const fn with_timestamp(self, ts_unix_nanos: u128) -> Self
pub const fn with_timestamp(self, ts_unix_nanos: u128) -> Self
Replace the timestamp.