Skip to content

Commit

Permalink
Merge pull request #99 from zjp-CN/master
Browse files Browse the repository at this point in the history
fix the problem of macro hygiene when paris is enabled
  • Loading branch information
Drakulix committed Apr 19, 2022
2 parents 44a294f + 568309c commit ba17254
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
9 changes: 9 additions & 0 deletions examples/paris_demo/Cargo.toml
@@ -0,0 +1,9 @@
[package]
name = "paris_demo"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
simplelog = { path = "../../", features = ["paris"] }
8 changes: 8 additions & 0 deletions examples/paris_demo/src/main.rs
@@ -0,0 +1,8 @@
fn main() {
simplelog::TermLogger::init(simplelog::LevelFilter::Debug,
simplelog::Config::default(),
simplelog::TerminalMode::Mixed,
simplelog::ColorChoice::Auto).expect("Failed to start simplelog");

simplelog::info!("I can write <b>bold</b> text or use tags to <red>color it</>");
}
6 changes: 5 additions & 1 deletion src/lib.rs
Expand Up @@ -45,7 +45,11 @@ use log::*;
#[cfg(feature = "paris")]
pub(crate) mod paris_macros;
#[cfg(feature = "paris")]
pub extern crate paris;
#[doc(hidden)]
pub mod __private {
pub use log;
pub use paris;
}

/// Trait to have a common interface to obtain the Level of Loggers
///
Expand Down
10 changes: 5 additions & 5 deletions src/paris_macros/mod.rs
Expand Up @@ -21,7 +21,7 @@
#[macro_export]
macro_rules! info {
($($args:tt)+) => {
log::info!("{}", paris::formatter::colorize_string(format!($($args)*)));
$crate::__private::log::info!("{}", $crate::__private::paris::formatter::colorize_string(format!($($args)*)));
};
}

Expand All @@ -47,7 +47,7 @@ macro_rules! info {
#[macro_export]
macro_rules! debug {
($($args:tt)+) => {
log::debug!("{}", paris::formatter::colorize_string(format!($($args)*)));
$crate::__private::log::debug!("{}", $crate::__private::paris::formatter::colorize_string(format!($($args)*)));
};
}

Expand Down Expand Up @@ -75,7 +75,7 @@ macro_rules! debug {
#[macro_export]
macro_rules! trace {
($($args:tt)+) => {
log::trace!("{}", paris::formatter::colorize_string(format!($($args)*)));
$crate::__private::log::trace!("{}", $crate::__private::paris::formatter::colorize_string(format!($($args)*)));
};
}

Expand All @@ -100,7 +100,7 @@ macro_rules! trace {
#[macro_export]
macro_rules! warn {
($($args:tt)+) => {
log::warn!("{}", paris::formatter::colorize_string(format!($($args)*)));
$crate::__private::log::warn!("{}", $crate::__private::paris::formatter::colorize_string(format!($($args)*)));
};
}

Expand All @@ -125,6 +125,6 @@ macro_rules! warn {
#[macro_export]
macro_rules! error {
($($args:tt)+) => {
log::error!("{}", paris::formatter::colorize_string(format!($($args)*)));
$crate::__private::log::error!("{}", $crate::__private::paris::formatter::colorize_string(format!($($args)*)));
};
}

0 comments on commit ba17254

Please sign in to comment.