fixed logger to work correctly

unstable
Penguin 3 years ago
parent a20b11b539
commit a1ac14b456

@ -14,47 +14,47 @@ pub fn igloo_subcommand(args: &ArgMatches) -> Result<IglooType, IglooStatus>
{
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!(),

@ -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<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();
target_manifest.merge(
config::File::with_name(
@ -45,6 +49,10 @@ impl IglooTargetManifest
.to_str().unwrap()
)).unwrap();
let ret = target_manifest.try_into::<IglooTargetManifest>().unwrap();
igloo_debug!(INFO,
IS_NONE,
"Target Manifest deserialized: \n{:?}", ret);
Ok(ret)
}
}

@ -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
);
}
}
};
}

@ -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)
}

Loading…
Cancel
Save