mod config;
mod display;
mod logging;
pub(crate) mod writer;
pub use config::{OutputConfig, OutputMode};
use once_cell::sync::OnceCell;
use std::sync::RwLock;
static OUTPUT_CONFIG: OnceCell<RwLock<OutputConfig>> = OnceCell::new();
pub fn init(mode: OutputMode) {
init_with_verbosity(mode, false);
}
pub fn init_with_verbosity(mode: OutputMode, verbose: bool) {
let mut config = OutputConfig::new(mode);
if verbose {
config.set_verbose();
}
config.init_tracing();
OUTPUT_CONFIG
.set(RwLock::new(config))
.expect("Output system already initialized");
}
pub(crate) fn config() -> &'static RwLock<OutputConfig> {
OUTPUT_CONFIG.get().expect("Output system not initialized")
}
pub fn is_initialized() -> bool {
OUTPUT_CONFIG.get().is_some()
}
pub fn current_mode() -> OutputMode {
if let Some(config) = OUTPUT_CONFIG.get() {
config.read().unwrap().mode()
} else {
OutputMode::Cli
}
}