filter logs by request id

This commit is contained in:
Robin Appelman 2024-12-17 17:34:21 +01:00
commit 8cebac7905
2 changed files with 14 additions and 3 deletions

View file

@ -83,7 +83,14 @@ impl LogMatch {
filter.matches(statement.pattern)
|| filter.matches(statement.path)
|| filter.matches(statement.path_prefix)
|| statement.placeholders.iter().any(|placeholder| filter.matches(placeholder))
|| statement
.placeholders
.iter()
.any(|placeholder| filter.matches(placeholder))
|| statement
.exception
.filter(|exception| filter.matches(exception))
.is_some()
})
}
}

View file

@ -21,6 +21,8 @@ pub const TIME_FORMAT: EncodedConfig = Config::DEFAULT
pub struct LogLine<'a> {
#[serde(default)]
pub index: usize,
#[serde(rename = "reqId")]
pub request_id: TinyAsciiStr<32>,
pub version: &'a str,
pub level: LogLevel,
pub message: Cow<'a, str>,
@ -131,8 +133,10 @@ impl<'a> LogLine<'a> {
if filter.is_empty() {
return true;
}
// todo: reqid, more?
filter.matches(&self.app) || filter.matches(&self.message)
// todo: exception, more?
filter.matches(&self.app)
|| filter.matches(&self.message)
|| filter.matches(self.request_id.as_str())
}
}