From 9acc7374b0e48d0c862bda0e02ae524a756e38cd Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Tue, 11 Aug 2020 22:53:57 +0800 Subject: [PATCH] Log module_path to target under std (#181) --- xpallets/contracts/src/lib.rs | 2 +- xpallets/support/src/macros.rs | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/xpallets/contracts/src/lib.rs b/xpallets/contracts/src/lib.rs index 4e38fd5bda9eb..882f340d4d79b 100644 --- a/xpallets/contracts/src/lib.rs +++ b/xpallets/contracts/src/lib.rs @@ -646,7 +646,7 @@ decl_module! { let params = (origin.clone(), value).encode(); if let Err(_e) = Self::call_for_xrc20(id, XRC20Selector::Issue, params.clone()) { - error!("[force_issue_xrc20]|{:?}|who:{:?}|value:{:?}|params:{:?}", _e.reason, origin, value, try_hex!(¶ms)) + error!("[force_issue_xrc20]|{:?}|who:{:?}|value:{:?}|params:{:?}", _e.reason, origin, value, try_hex!(¶ms)); } } Ok(()) diff --git a/xpallets/support/src/macros.rs b/xpallets/support/src/macros.rs index 04390f711faec..00ff8858fd296 100644 --- a/xpallets/support/src/macros.rs +++ b/xpallets/support/src/macros.rs @@ -85,6 +85,9 @@ pub mod log { frame_support::debug::error!(target: $target, $($arg)+); ); ($($arg:tt)+) => ( + #[cfg(feature = "std")] + $crate::error!(target: &format!("runtime::{}:{}", module_path!(), line!()), $($arg)+); + #[cfg(not(feature = "std"))] $crate::error!(target: "runtime", $($arg)+); ) } @@ -95,6 +98,9 @@ pub mod log { frame_support::debug::warn!(target: $target, $($arg)+); ); ($($arg:tt)+) => ( + #[cfg(feature = "std")] + $crate::warn!(target: &format!("runtime::{}:{}", module_path!(), line!()), $($arg)+); + #[cfg(not(feature = "std"))] $crate::warn!(target: "runtime", $($arg)+); ) } @@ -105,6 +111,9 @@ pub mod log { frame_support::debug::info!(target: $target, $($arg)+); ); ($($arg:tt)+) => ( + #[cfg(feature = "std")] + $crate::info!(target: &format!("runtime::{}", module_path!()), $($arg)+); + #[cfg(not(feature = "std"))] $crate::info!(target: "runtime", $($arg)+); ) } @@ -115,6 +124,9 @@ pub mod log { frame_support::debug::debug!(target: $target, $($arg)+); ); ($($arg:tt)+) => ( + #[cfg(feature = "std")] + $crate::debug!(target: &format!("runtime::{}:{}", module_path!(), line!()), $($arg)+); + #[cfg(not(feature = "std"))] $crate::debug!(target: "runtime", $($arg)+); ) } @@ -125,6 +137,9 @@ pub mod log { frame_support::debug::trace!(target: $target, $($arg)+); ); ($($arg:tt)+) => ( + #[cfg(feature = "std")] + $crate::trace!(target: &format!("runtime::{}:{}", module_path!(), line!()), $($arg)+); + #[cfg(not(feature = "std"))] $crate::trace!(target: "runtime", $($arg)+); ) }