use std::sync::{Arc, OnceLock};
use crate::util::debug_log::{format_with_args, DebugLog};
pub trait ILogContext: Send + Sync {
fn log_debug(&self, category: &str, message: &str);
fn log_debug_args(&self, category: &str, message: &str, args: &[&str]) {
self.log_debug(category, &format_with_args(message, args));
}
}
#[derive(Debug)]
pub(crate) struct DebugLogContext;
impl DebugLogContext {
pub(crate) fn instance() -> Arc<dyn ILogContext> {
static INSTANCE: OnceLock<Arc<dyn ILogContext>> = OnceLock::new();
INSTANCE
.get_or_init(|| Arc::new(DebugLogContext))
.clone()
}
}
impl ILogContext for DebugLogContext {
fn log_debug(&self, category: &str, message: &str) {
DebugLog::write_line(category, message);
}
}