Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the problem of macro hygiene when paris is enabled #99

Merged
merged 2 commits into from Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -44,7 +44,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)*)));
};
}