master > master: code-rust - log
This commit is contained in:
parent
f192559eca
commit
d0099eb7f9
57
code/rust/src/core/log.rs
Normal file
57
code/rust/src/core/log.rs
Normal file
@ -0,0 +1,57 @@
|
||||
// ----------------------------------------------------------------
|
||||
// IMPORTS
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
//
|
||||
|
||||
// ----------------------------------------------------------------
|
||||
// METHODS log
|
||||
// ----------------------------------------------------------------
|
||||
|
||||
/// Prints an info message
|
||||
#[macro_export]
|
||||
macro_rules! log_info{
|
||||
($text:expr $(, $args:expr)* $(,)?)=>{
|
||||
print!("[\x1b[94;1mINFO\x1b[0m] ");
|
||||
println!($text$(, $args )*);
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints a debug message
|
||||
#[macro_export]
|
||||
macro_rules! log_debug{
|
||||
($text:expr $(, $args:expr)* $(,)?)=>{
|
||||
print!("[\x1b[96;1mDEBUG\x1b[95;0m] ");
|
||||
println!($text$(, $args )*);
|
||||
}
|
||||
}
|
||||
#[allow(unused_imports)]
|
||||
pub(crate) use log_debug;
|
||||
|
||||
// pub(crate) use log_debug;
|
||||
|
||||
/// Prints a warning message
|
||||
#[macro_export]
|
||||
macro_rules! log_warn{
|
||||
($text:expr $(, $args:expr)* $(,)?)=>{
|
||||
print!("[\x1b[93;1mWARNING\x1b[0m] ");
|
||||
println!($text$(, $args )*);
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints an error message
|
||||
#[macro_export]
|
||||
macro_rules! log_error{
|
||||
($text:expr $(, $args:expr)* $(,)?)=>{
|
||||
print!("[\x1b[91;1mERROR\x1b[0m] ");
|
||||
println!($text$(, $args )*);
|
||||
}
|
||||
}
|
||||
|
||||
/// Prints a fatal error message + crashes
|
||||
#[macro_export]
|
||||
macro_rules! log_fatal{
|
||||
($text:expr $(, $args:expr)* $(,)?)=>{
|
||||
panic!("[\x1b[91;1mFATAL\x1b[0m] {}", format!($text$(, $args )*));
|
||||
}
|
||||
}
|
@ -1 +1,2 @@
|
||||
pub mod log;
|
||||
pub mod utils;
|
||||
|
Loading…
x
Reference in New Issue
Block a user