pub struct LogRecord {
pub ts: i64,
pub level: LogLevel,
pub message: String,
pub attrs: BTreeMap<String, AttrValue>,
pub logger: Option<String>,
pub seq: i64,
pub revision: Option<i64>,
}Expand description
One application log record.
ts is Unix epoch milliseconds, not session-relative: an adapter has no
reliable view of when the driver considers the session to have started, so
the wall clock is the only clock both sides agree on without negotiating.
The driver rebases it onto the session timeline.
Fields§
§ts: i64Unix epoch milliseconds when the record was produced.
level: LogLevelSeverity.
message: StringHuman-readable message, already formatted by the source logger.
attrs: BTreeMap<String, AttrValue>Flat structured context; sorted so a record serialises the same way twice.
logger: Option<String>Logger or channel name, e.g. http or db.pool.
seq: i64Per-session counter assigned by the adapter. A gap tells the driver records were dropped upstream rather than lost in transit.
revision: Option<i64>Semantic revision current when the record was produced, when known.
Implementations§
Source§impl LogRecord
impl LogRecord
Sourcepub fn new(level: LogLevel, message: impl Into<String>) -> Self
pub fn new(level: LogLevel, message: impl Into<String>) -> Self
A record with only the required fields. seq is assigned by the client.
Sourcepub fn with_attr(
self,
key: impl Into<String>,
value: impl Into<AttrValue>,
) -> Self
pub fn with_attr( self, key: impl Into<String>, value: impl Into<AttrValue>, ) -> Self
Add one flat attribute.
Sourcepub fn with_logger(self, logger: impl Into<String>) -> Self
pub fn with_logger(self, logger: impl Into<String>) -> Self
Name the logger this record came from.
Sourcepub fn validate(&self, limits: &Limits) -> Result<(), ValidationError>
pub fn validate(&self, limits: &Limits) -> Result<(), ValidationError>
Validate against limits, as the driver will.
§Errors
Returns a ValidationError with the shared taxonomy.