mod tracing_isa;
mod disable;
mod pretty_print;

#[cfg(feature = "tracing")]
use std::{fs::File, path::{ PathBuf}};
use std::sync::{LazyLock, Mutex};

use crate::Executable;

#[cfg(feature = "tracing")]
pub struct Trace {
    out_files : Vec<File>
}


#[cfg(feature = "tracing")]
impl Trace {
    fn new() -> Self {
        Self { out_files : Vec::new()}
    }


    pub fn init(&mut self, num_core : usize , mut path :  PathBuf) {
        path.pop();
        for i in 0..num_core {
            path.push(format!("TraceCore{}", i));
            let file = File::create(&path).expect("Can not create file");
            self.out_files.push(file);
            path.pop();
        }
    }
}

#[cfg(not(feature = "tracing"))]
pub struct Trace {
}


#[cfg(not(feature = "tracing"))]
impl Trace {
    fn new() -> Self {
        Self {  }
    }


    pub fn init(&mut self, num_core : usize, path : PathBuf ) {
    }
}


pub static TRACER: LazyLock<Mutex<Trace>> = LazyLock::new(|| { Trace::new().into()});

