fixed logger to work correctly

unstable
Penguin 2 years ago
parent a20b11b539
commit a1ac14b456

@ -14,47 +14,47 @@ pub fn igloo_subcommand(args: &ArgMatches) -> Result<IglooType, IglooStatus>
{ {
Some("new") => Some("new") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo new was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo new was called!");
_res_type = IT_NEW; _res_type = IT_NEW;
} }
Some("run") => Some("run") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo run was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo run was called!");
_res_type = IT_RUN; _res_type = IT_RUN;
} }
Some("build") => Some("build") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo build was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo build was called!");
_res_type = IT_BUILD; _res_type = IT_BUILD;
} }
Some("push") => Some("push") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo flash was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo flash was called!");
_res_type = IT_PUSH; _res_type = IT_PUSH;
} }
Some("pull") => Some("pull") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo pull was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo pull was called!");
_res_type = IT_PULL; _res_type = IT_PULL;
} }
Some("erase") => Some("erase") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo erase was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo erase was called!");
_res_type = IT_ERASE; _res_type = IT_ERASE;
} }
Some("info") => Some("info") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo info was called!"); igloo_debug!(TRACE, IS_NONE, "Igloo info was called!");
_res_type = IT_INFO; _res_type = IT_INFO;
} }
Some("target") => Some("target") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo target was called"); igloo_debug!(TRACE, IS_NONE, "Igloo target was called");
_res_type = IT_TARGET; _res_type = IT_TARGET;
} }
Some("debug") => Some("debug") =>
{ {
igloo_debug!(TRACE, IS_GOOD, "Igloo debug was called"); igloo_debug!(TRACE, IS_NONE, "Igloo debug was called");
_res_type = IT_DEBUG; _res_type = IT_DEBUG;
} }
None => unreachable!(), None => unreachable!(),

@ -4,13 +4,12 @@ use std::collections::HashMap;
use std::vec::Vec; use std::vec::Vec;
use crate::Igloo; use crate::Igloo;
use crate::IglooStatus; use crate::IglooStatus::{self, *};
use crate::IglooStatus::*; use crate::IglooType::{self, *};
use crate::IglooDebugSeverity::{self, *};
use crate::IglooType;
use crate::IglooType::*;
use crate::igloo_target::IglooTarget; use crate::igloo_target::IglooTarget;
use crate::igloo_util::*;
use serde::{Serialize, Deserialize}; use serde::{Serialize, Deserialize};
use config::Config; use config::Config;
@ -34,6 +33,11 @@ impl IglooTargetManifest
} }
pub fn get(igloo: &Igloo) -> Result<IglooTargetManifest, IglooStatus> pub fn get(igloo: &Igloo) -> Result<IglooTargetManifest, IglooStatus>
{ {
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(); let mut target_manifest = config::Config::default();
target_manifest.merge( target_manifest.merge(
config::File::with_name( config::File::with_name(
@ -45,6 +49,10 @@ impl IglooTargetManifest
.to_str().unwrap() .to_str().unwrap()
)).unwrap(); )).unwrap();
let ret = target_manifest.try_into::<IglooTargetManifest>().unwrap(); let ret = target_manifest.try_into::<IglooTargetManifest>().unwrap();
igloo_debug!(INFO,
IS_NONE,
"Target Manifest deserialized: \n{:?}", ret);
Ok(ret) Ok(ret)
} }
} }

@ -7,27 +7,33 @@ macro_rules! igloo_debug
{ {
($severity:expr, $status:expr) => ($severity:expr, $status:expr) =>
{ {
if TRACE_LEVEL.clone() as u8 <= $severity as u8 if cfg!(debug_assertions)
{ {
println!("[{:?}]: Line {:?} in {:?} | {:?}", if $severity as u8 <= TRACE_LEVEL.clone() as u8
$severity, {
line!(), println!("[{:?}]: Line {:?} in {:?} | {:?}",
file!(), $severity,
$status); line!(),
file!(),
$status);
}
} }
}; };
($severity:expr, $status:expr, $($message:tt)*) => ($severity:expr, $status:expr, $($message:tt)*) =>
{ {
if TRACE_LEVEL.clone() as u8 <= $severity as u8 if cfg!(debug_assertions)
{ {
println!("[{:?}]: Line {:?} in {:?} | {:?} -- {}", if $severity as u8 <= TRACE_LEVEL.clone() as u8
$severity, {
line!(), println!("[{:?}]: Line {:?} in {} | {} -- STATUS: {:?}",
file!(), $severity,
$status, line!(),
format_args!($($message)*) file!(),
); format_args!($($message)*),
$status
);
}
} }
}; };
} }

@ -42,20 +42,22 @@ pub enum IglooType
#[derive(Debug, PartialEq, Clone)] #[derive(Debug, PartialEq, Clone)]
pub enum IglooDebugSeverity pub enum IglooDebugSeverity
{ {
CRITICAL = 0, ERROR = 0,
WARNING = 1, WARNING = 1,
INFO = 2, LOG = 2,
TRACE = 3, TRACE = 3,
INFO = 4,
} }
#[derive(Debug)] #[derive(Debug)]
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum IglooStatus pub enum IglooStatus
{ {
IS_GOOD = 0x00, IS_GOOD = 0x00,
IS_BAD = 0x01, IS_BAD = 0x01,
IS_UNKNOWN = 0x02, IS_UNKNOWN = 0x02,
IS_FAILED_TO_LOAD_MTM = 0x03, IS_FAILED_TO_LOAD_MTM = 0x03,
IS_NONE = 0xFF,
} }
use IglooStatus::*; use IglooStatus::*;
@ -90,12 +92,19 @@ impl Igloo
// get master target manifest // get master target manifest
self.master_target_manifest = IglooTargetManifest::get(self).unwrap(); 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 // get master make manifest
// this is a hacky way of doing it until // this is a hacky way of doing it until
// i can figure out a proper structure for deserializing // 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( self.master_make_manifest.merge(
config::File::with_name( config::File::with_name(
self.env self.env
@ -104,6 +113,8 @@ impl Igloo
.join("manifest") .join("manifest")
.join("make-manifest.toml") .join("make-manifest.toml")
.to_str().unwrap())).unwrap(); .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) // Assign instance type (new, run, push, etc)
igloo_action::igloo_subcommand(&self.cli_info.raw) igloo_action::igloo_subcommand(&self.cli_info.raw)
} }

Loading…
Cancel
Save