mirror of
https://github.com/Astatin3/unshell.git
synced 2026-06-08 22:38:01 -06:00
Make the log macro's definition more consise
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@ version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
authors = ["ASTATIN3"]
|
||||
include = ["LICENSE-APACHE", "LICENSE-MIT", "**/*.rs", "Cargo.toml"]
|
||||
include = ["LICENSE", "**/*.rs", "Cargo.toml"]
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
// Macros that are used that just drop the inside variables
|
||||
#[macro_export]
|
||||
macro_rules! log {
|
||||
($level:expr, $fmt:tt) => {{}};
|
||||
($level:expr, $fmt:tt, $($arg:expr),*) => {{}};
|
||||
}
|
||||
@@ -33,31 +33,3 @@ macro_rules! log {
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Debug, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Info, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Warn, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Error, $($arg)*)
|
||||
};
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
// Macros that are used that just drop the inside variables
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
($fmt:tt) => {{
|
||||
let _ = $fmt;
|
||||
}};
|
||||
($fmt:tt, $($arg:expr),*) => {{
|
||||
let _ = $fmt;
|
||||
$(let _ = $arg;)*
|
||||
}};
|
||||
}
|
||||
+31
-2
@@ -1,9 +1,9 @@
|
||||
// Choose if the macros are enabled based on the feature setting
|
||||
#[cfg(feature = "log")]
|
||||
pub mod macros;
|
||||
mod log_enabled;
|
||||
|
||||
#[cfg(not(feature = "log"))]
|
||||
pub mod macros_disabled;
|
||||
mod log_disabled;
|
||||
|
||||
mod pretty_logger;
|
||||
|
||||
@@ -81,3 +81,32 @@ pub type SetupLogger = extern "C" fn(logger: &'static dyn Logger);
|
||||
pub extern "C" fn setup_logger(logger: &'static dyn Logger) {
|
||||
set_logger(logger);
|
||||
}
|
||||
|
||||
// Macro Definitions
|
||||
#[macro_export]
|
||||
macro_rules! debug {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Debug, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! info {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Info, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! warn {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Warn, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! error {
|
||||
($($arg:tt)*) => {
|
||||
$crate::log!($crate::logger::LogLevel::Error, $($arg)*)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#![macro_use]
|
||||
extern crate unshell;
|
||||
|
||||
use unshell::{
|
||||
Value, info,
|
||||
logger::{Record, log},
|
||||
obfuscate::{junk_asm, symbol},
|
||||
tree::{Tree, TreeElement, symbols},
|
||||
};
|
||||
@@ -31,9 +33,9 @@ fn test123(manager: &mut Tree) -> bool {
|
||||
|
||||
let is_null = result.is_null();
|
||||
|
||||
if let Ok(result) = serde_json::from_value::<Record>(result) {
|
||||
log(&result);
|
||||
}
|
||||
// if let Ok(result) = serde_json::from_value::<Record>(result) {
|
||||
// log(&result);
|
||||
// }
|
||||
|
||||
is_null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user