use env_logger::Target;
use rustyline_async::SharedWriter;
use tracing_log::log::LevelFilter;

pub fn init_tracing(out: Option<SharedWriter>) {
    #[cfg(target_os = "windows")]
    ansi_term::enable_ansi_support().unwrap();

    let target = match out {
        Some(out) => Target::Pipe(Box::new(out)),
        None => Target::Stdout,
    };

    env_logger::builder()
        .target(target)
        .filter(None, LevelFilter::Info)
        .init();
}
