#[cfg(feature = "tracing")]
use async_trait::async_trait;
#[cfg(feature = "tracing")]
use crate::domain::A2AError;
#[cfg(feature = "tracing")]
use crate::port::{CallContext, CallInterceptor};
#[cfg(feature = "tracing")]
#[derive(Debug, Clone, Default)]
pub struct LoggingInterceptor;
#[cfg(feature = "tracing")]
#[async_trait]
impl CallInterceptor for LoggingInterceptor {
async fn before(&self, ctx: &CallContext) -> Result<(), A2AError> {
tracing::debug!(method = %ctx.method, side = ?ctx.side, "A2A call started");
Ok(())
}
async fn after(&self, ctx: &CallContext, outcome: Result<(), &A2AError>) {
match outcome {
Ok(()) => {
tracing::debug!(method = %ctx.method, side = ?ctx.side, "A2A call succeeded")
}
Err(e) => {
tracing::warn!(method = %ctx.method, side = ?ctx.side, error = %e, "A2A call failed")
}
}
}
}