use super::{ChannelAdapter, ChannelError};
use crate::escalation::trait_::EscalationTicket;
use async_trait::async_trait;
pub struct LogChannel;
impl LogChannel {
#[must_use]
pub fn new() -> Self {
Self
}
}
impl Default for LogChannel {
fn default() -> Self {
Self::new()
}
}
#[async_trait]
impl ChannelAdapter for LogChannel {
async fn deliver(&self, ticket: &EscalationTicket) -> Result<(), ChannelError> {
tracing::warn!(
tenant = ?ticket.tenant,
severity = ?ticket.severity,
reason = %ticket.reason,
provenance_run_id = ?ticket.provenance.as_ref().map(|p| &p.run_id),
"escalation ticket"
);
Ok(())
}
fn name(&self) -> &'static str {
"LogChannel"
}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::escalation::trait_::{EscalationTicket, Severity};
#[tokio::test]
async fn log_channel_delivers_ok() {
let ch = LogChannel::new();
let ticket = EscalationTicket {
tenant: None,
severity: Severity::High,
reason: "test".into(),
provenance: None,
};
ch.deliver(&ticket).await.expect("log channel delivers");
}
}