use crate::output::{format::FormatOutput, msg::OutputMsg, output::OutputType};
use super::output::Output;
pub struct TracingOutput {
formatter: FormatOutput,
}
impl TracingOutput {
pub fn new(level: &str, formatter: FormatOutput) -> Self {
let filter = format!("vibe_action={}", level);
let _ = tracing_subscriber::fmt().with_env_filter(filter).try_init();
Self { formatter }
}
}
impl Output for TracingOutput {
fn output_type(&self) -> OutputType {
OutputType::Tracing
}
fn plain(&self, msg: &OutputMsg) {
tracing::info!("{}", self.formatter.format(msg));
}
fn error(&self, msg: &OutputMsg) {
tracing::error!("{}", self.formatter.format(msg));
}
fn warning(&self, msg: &OutputMsg) {
tracing::warn!("{}", self.formatter.format(msg));
}
fn info(&self, msg: &OutputMsg) {
tracing::info!("{}", self.formatter.format(msg));
}
fn success(&self, msg: &OutputMsg) {
tracing::info!("{}", self.formatter.format(msg));
}
fn debug(&self, msg: &OutputMsg) {
tracing::debug!("{}", self.formatter.format(msg));
}
fn trace(&self, msg: &OutputMsg) {
tracing::trace!("{}", self.formatter.format(msg));
}
fn progress(&self, msg: &OutputMsg) {
tracing::trace!("{}", self.formatter.format(msg));
}
}