mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2025-12-17 04:39:01 -05:00
tracing capture interface
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1bb4021b90
commit
aa34021b27
15 changed files with 284 additions and 27 deletions
31
src/core/log/capture/data.rs
Normal file
31
src/core/log/capture/data.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
use tracing::Level;
|
||||
use tracing_core::{span::Current, Event};
|
||||
|
||||
use super::layer::Value;
|
||||
|
||||
pub struct Data<'a> {
|
||||
pub event: &'a Event<'a>,
|
||||
pub current: &'a Current,
|
||||
pub values: Option<&'a mut [Value]>,
|
||||
}
|
||||
|
||||
impl Data<'_> {
|
||||
#[must_use]
|
||||
pub fn level(&self) -> Level { *self.event.metadata().level() }
|
||||
|
||||
#[must_use]
|
||||
pub fn mod_name(&self) -> &str { self.event.metadata().module_path().unwrap_or_default() }
|
||||
|
||||
#[must_use]
|
||||
pub fn span_name(&self) -> &str { self.current.metadata().map_or("", |s| s.name()) }
|
||||
|
||||
#[must_use]
|
||||
pub fn message(&self) -> &str {
|
||||
self.values
|
||||
.as_ref()
|
||||
.expect("values are not composed for a filter")
|
||||
.iter()
|
||||
.find(|(k, _)| *k == "message")
|
||||
.map_or("", |(_, v)| v.as_str())
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue