diff --git a/src/compiler/compiler_source.rs b/src/compiler/compiler_source.rs index 985d319..c6cbc0a 100644 --- a/src/compiler/compiler_source.rs +++ b/src/compiler/compiler_source.rs @@ -1,6 +1,7 @@ use std::fs::File; use std::io::Read; use std::path::{Path, PathBuf}; +use crate::util::logger; pub(crate) trait CompilerSource { fn read(&self) -> Result; @@ -20,6 +21,7 @@ impl FileCompilerSource { impl CompilerSource for FileCompilerSource { fn read(&self) -> Result { + logger::debug!("Reading source file: {:?}", self.path); let mut p = File::open(self.path.clone())?; let mut buff = String::new(); p.read_to_string(&mut buff)?; diff --git a/src/util/logger.rs b/src/util/logger.rs index 17a3865..0131737 100644 --- a/src/util/logger.rs +++ b/src/util/logger.rs @@ -80,60 +80,68 @@ lazy_static!( macro_rules! debug { ($($arg:tt)*) => { - let instance = crate::util::logger::INSTANCE.lock().unwrap(); - if *instance.level() <= crate::util::logger::LogLevel::Debug { - instance.debug( - format!( - "{}: {}", - module_path!(), - format!($($arg)*).as_str() - ).as_str() - ); + { + let instance = crate::util::logger::INSTANCE.lock().unwrap(); + if *instance.level() <= crate::util::logger::LogLevel::Debug { + instance.debug( + format!( + "{}: {}", + module_path!(), + format!($($arg)*).as_str() + ).as_str() + ); + } } }; } macro_rules! error { ($($arg:tt)*) => { - let instance = crate::util::logger::INSTANCE.lock().unwrap(); - if *instance.level() <= crate::util::logger::LogLevel::Error { - instance.error( - format!( - "{}: {}", - module_path!(), - format!($($arg)*).as_str() - ).as_str() - ); + { + let instance = crate::util::logger::INSTANCE.lock().unwrap(); + if *instance.level() <= crate::util::logger::LogLevel::Error { + instance.error( + format!( + "{}: {}", + module_path!(), + format!($($arg)*).as_str() + ).as_str() + ); + } } }; } macro_rules! info { ($($arg:tt)*) => { - let instance = crate::util::logger::INSTANCE.lock().unwrap(); - if *instance.level() <= crate::util::logger::LogLevel::Info { - instance.info( - format!( - "{}: {}", - module_path!(), - format!($($arg)*).as_str() - ).as_str() - ); + { + let instance = crate::util::logger::INSTANCE.lock().unwrap(); + if *instance.level() <= crate::util::logger::LogLevel::Info { + instance.info( + format!( + "{}: {}", + module_path!(), + format!($($arg)*).as_str() + ).as_str() + ); + } } }; } -macro_rules! warn { +macro_rules! warning { ($($arg:tt)*) => { - let instance = crate::util::logger::INSTANCE.lock().unwrap(); - if *instance.level() <= crate::util::logger::LogLevel::Warn { - instance.warn( - format!( - "{}: {}", - module_path!(), - format!($($arg)*).as_str() - ).as_str() - ); + { + let instance = crate::util::logger::INSTANCE.lock().unwrap(); + if *instance.level() <= crate::util::logger::LogLevel::Warn { + instance.warn( + format!( + "{}: {}", + module_path!(), + format!($($arg)*).as_str() + ).as_str() + ); + } } }; } @@ -147,4 +155,4 @@ macro_rules! output { }; } -pub(crate) use {debug, output, error}; \ No newline at end of file +pub(crate) use {debug, output, error, info, warning}; \ No newline at end of file