add our_modules() for log capture filter convenience
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
94b805de0b
commit
9b9a91f6ef
|
@ -87,7 +87,7 @@ fn reply(mut content: RoomMessageEventContent, reply_id: Option<OwnedEventId>) -
|
|||
// Parse and process a message from the admin room
|
||||
async fn process(context: &Command<'_>, command: AdminCommand, args: &[String]) -> CommandOutput {
|
||||
let filter: &capture::Filter =
|
||||
&|data| data.level() <= Level::DEBUG && data.mod_name().starts_with("conduit") && data.scope.contains(&"admin");
|
||||
&|data| data.level() <= Level::DEBUG && data.our_modules() && data.scope.contains(&"admin");
|
||||
let logs = Arc::new(Mutex::new(
|
||||
collect_stream(|s| markdown_table_head(s)).expect("markdown table header"),
|
||||
));
|
||||
|
|
|
@ -6,3 +6,6 @@ pub mod rustc;
|
|||
pub mod version;
|
||||
|
||||
pub use conduit_macros::rustc_flags_capture;
|
||||
|
||||
pub const MODULE_ROOT: &str = const_str::split!(std::module_path!(), "::")[0];
|
||||
pub const CRATE_PREFIX: &str = const_str::split!(MODULE_ROOT, '_')[0];
|
||||
|
|
|
@ -2,6 +2,7 @@ use tracing::Level;
|
|||
use tracing_core::{span::Current, Event};
|
||||
|
||||
use super::{layer::Value, Layer};
|
||||
use crate::{info, utils::string::EMPTY};
|
||||
|
||||
pub struct Data<'a> {
|
||||
pub layer: &'a Layer,
|
||||
|
@ -12,6 +13,9 @@ pub struct Data<'a> {
|
|||
}
|
||||
|
||||
impl Data<'_> {
|
||||
#[must_use]
|
||||
pub fn our_modules(&self) -> bool { self.mod_name().starts_with(info::CRATE_PREFIX) }
|
||||
|
||||
#[must_use]
|
||||
pub fn level(&self) -> Level { *self.event.metadata().level() }
|
||||
|
||||
|
@ -19,13 +23,13 @@ impl Data<'_> {
|
|||
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()) }
|
||||
pub fn span_name(&self) -> &str { self.current.metadata().map_or(EMPTY, |s| s.name()) }
|
||||
|
||||
#[must_use]
|
||||
pub fn message(&self) -> &str {
|
||||
self.values
|
||||
.iter()
|
||||
.find(|(k, _)| *k == "message")
|
||||
.map_or("", |(_, v)| v.as_str())
|
||||
.map_or(EMPTY, |(_, v)| v.as_str())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue