talos_plugin/builtin/
logging.rs1use async_trait::async_trait;
4
5use crate::event::{ALL_HOOK_EVENT_KINDS, HookEvent, HookEventKind};
6use crate::handler::{HookContext, HookHandler, HookResult};
7
8#[derive(Debug, Default)]
10pub struct LoggingHandler;
11
12impl LoggingHandler {
13 #[must_use]
15 pub fn new() -> Self {
16 Self
17 }
18}
19
20#[async_trait]
21impl HookHandler for LoggingHandler {
22 fn name(&self) -> &str {
23 "LoggingHandler"
24 }
25
26 fn subscribed(&self) -> &'static [HookEventKind] {
27 &ALL_HOOK_EVENT_KINDS
28 }
29
30 async fn on_event(&self, ctx: &HookContext, event: &mut HookEvent<'_>) -> HookResult {
31 tracing::debug!(
32 handler = self.name(),
33 event = %event.kind(),
34 turn_id = ctx.turn_id.0,
35 "hook event"
36 );
37 HookResult::Continue
38 }
39}