From a1ac14b456b940982a62b8876c950c6446e04e98 Mon Sep 17 00:00:00 2001 From: Penguin Date: Thu, 23 Dec 2021 19:26:30 -0600 Subject: [PATCH] fixed logger to work correctly --- igloo_core/src/igloo_action.rs | 18 ++++++++--------- igloo_core/src/igloo_manifest.rs | 18 ++++++++++++----- igloo_core/src/igloo_util.rs | 34 +++++++++++++++++++------------- igloo_core/src/lib.rs | 29 ++++++++++++++++++--------- 4 files changed, 62 insertions(+), 37 deletions(-) diff --git a/igloo_core/src/igloo_action.rs b/igloo_core/src/igloo_action.rs index 3c554c4..eb76054 100644 --- a/igloo_core/src/igloo_action.rs +++ b/igloo_core/src/igloo_action.rs @@ -14,47 +14,47 @@ pub fn igloo_subcommand(args: &ArgMatches) -> Result { Some("new") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo new was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo new was called!"); _res_type = IT_NEW; } Some("run") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo run was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo run was called!"); _res_type = IT_RUN; } Some("build") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo build was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo build was called!"); _res_type = IT_BUILD; } Some("push") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo flash was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo flash was called!"); _res_type = IT_PUSH; } Some("pull") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo pull was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo pull was called!"); _res_type = IT_PULL; } Some("erase") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo erase was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo erase was called!"); _res_type = IT_ERASE; } Some("info") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo info was called!"); + igloo_debug!(TRACE, IS_NONE, "Igloo info was called!"); _res_type = IT_INFO; } Some("target") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo target was called"); + igloo_debug!(TRACE, IS_NONE, "Igloo target was called"); _res_type = IT_TARGET; } Some("debug") => { - igloo_debug!(TRACE, IS_GOOD, "Igloo debug was called"); + igloo_debug!(TRACE, IS_NONE, "Igloo debug was called"); _res_type = IT_DEBUG; } None => unreachable!(), diff --git a/igloo_core/src/igloo_manifest.rs b/igloo_core/src/igloo_manifest.rs index 1b6baf7..03df546 100644 --- a/igloo_core/src/igloo_manifest.rs +++ b/igloo_core/src/igloo_manifest.rs @@ -4,13 +4,12 @@ use std::collections::HashMap; use std::vec::Vec; use crate::Igloo; -use crate::IglooStatus; -use crate::IglooStatus::*; - -use crate::IglooType; -use crate::IglooType::*; +use crate::IglooStatus::{self, *}; +use crate::IglooType::{self, *}; +use crate::IglooDebugSeverity::{self, *}; use crate::igloo_target::IglooTarget; +use crate::igloo_util::*; use serde::{Serialize, Deserialize}; use config::Config; @@ -34,6 +33,11 @@ impl IglooTargetManifest } pub fn get(igloo: &Igloo) -> Result { + igloo_debug!(TRACE, + IS_NONE, + "Reading master target manifest from {}", + igloo.env.esfd.join("manifest").join("target-manifest.toml").to_str().unwrap()); + let mut target_manifest = config::Config::default(); target_manifest.merge( config::File::with_name( @@ -45,6 +49,10 @@ impl IglooTargetManifest .to_str().unwrap() )).unwrap(); let ret = target_manifest.try_into::().unwrap(); + + igloo_debug!(INFO, + IS_NONE, + "Target Manifest deserialized: \n{:?}", ret); Ok(ret) } } diff --git a/igloo_core/src/igloo_util.rs b/igloo_core/src/igloo_util.rs index a6d7fdf..fab3bf3 100644 --- a/igloo_core/src/igloo_util.rs +++ b/igloo_core/src/igloo_util.rs @@ -7,27 +7,33 @@ macro_rules! igloo_debug { ($severity:expr, $status:expr) => { - if TRACE_LEVEL.clone() as u8 <= $severity as u8 + if cfg!(debug_assertions) { - println!("[{:?}]: Line {:?} in {:?} | {:?}", - $severity, - line!(), - file!(), - $status); + if $severity as u8 <= TRACE_LEVEL.clone() as u8 + { + println!("[{:?}]: Line {:?} in {:?} | {:?}", + $severity, + line!(), + file!(), + $status); + } } }; ($severity:expr, $status:expr, $($message:tt)*) => { - if TRACE_LEVEL.clone() as u8 <= $severity as u8 + if cfg!(debug_assertions) { - println!("[{:?}]: Line {:?} in {:?} | {:?} -- {}", - $severity, - line!(), - file!(), - $status, - format_args!($($message)*) - ); + if $severity as u8 <= TRACE_LEVEL.clone() as u8 + { + println!("[{:?}]: Line {:?} in {} | {} -- STATUS: {:?}", + $severity, + line!(), + file!(), + format_args!($($message)*), + $status + ); + } } }; } diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index bc0c81b..b7ce9d6 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -42,20 +42,22 @@ pub enum IglooType #[derive(Debug, PartialEq, Clone)] pub enum IglooDebugSeverity { - CRITICAL = 0, + ERROR = 0, WARNING = 1, - INFO = 2, + LOG = 2, TRACE = 3, + INFO = 4, } #[derive(Debug)] #[derive(PartialEq)] pub enum IglooStatus { - IS_GOOD = 0x00, - IS_BAD = 0x01, - IS_UNKNOWN = 0x02, - IS_FAILED_TO_LOAD_MTM = 0x03, + IS_GOOD = 0x00, + IS_BAD = 0x01, + IS_UNKNOWN = 0x02, + IS_FAILED_TO_LOAD_MTM = 0x03, + IS_NONE = 0xFF, } use IglooStatus::*; @@ -90,12 +92,19 @@ impl Igloo // get master target manifest self.master_target_manifest = IglooTargetManifest::get(self).unwrap(); - igloo_debug!(TRACE, IS_GOOD, "Hello \n{:?}", self.master_target_manifest); - igloo_debug!(TRACE, IS_GOOD, "TEST"); - // get master make manifest // this is a hacky way of doing it until // i can figure out a proper structure for deserializing + igloo_debug!(TRACE, + IS_NONE, + "Reading master makefile manifest from {}", + self.env + .esfd + .clone() + .join("manifest") + .join("make-manifest.toml") + .to_str().unwrap()); + self.master_make_manifest.merge( config::File::with_name( self.env @@ -104,6 +113,8 @@ impl Igloo .join("manifest") .join("make-manifest.toml") .to_str().unwrap())).unwrap(); + + igloo_debug!(INFO, IS_NONE, "Read master makefile manifest: \n{:?}", self.master_make_manifest); // Assign instance type (new, run, push, etc) igloo_action::igloo_subcommand(&self.cli_info.raw) }