use std::any::Any;
use std::time::Duration;
use super::{TransactionObserver, TxnContext};
use crate::Result;
#[derive(Debug, Default, Clone, Copy)]
pub struct LogObserver;
impl TransactionObserver for LogObserver {
fn on_transact(&self, _ctx: &TxnContext<'_>) -> Option<Box<dyn Any + Send>> {
None
}
fn on_reply(
&self,
ctx: &TxnContext<'_>,
_tag: Option<Box<dyn Any + Send>>,
result: &Result<()>,
elapsed: Duration,
) {
match ctx.method {
Some(method) => log::debug!(
target: "rsbinder::observe",
"{}::{method} oneway={} uid={} pid={} elapsed={elapsed:?} result={result:?}",
ctx.descriptor, ctx.is_oneway, ctx.calling_uid, ctx.calling_pid,
),
None => log::debug!(
target: "rsbinder::observe",
"{} code={} oneway={} uid={} pid={} elapsed={elapsed:?} result={result:?}",
ctx.descriptor, ctx.code, ctx.is_oneway, ctx.calling_uid, ctx.calling_pid,
),
}
}
}