mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-13 10:25:50 +00:00
Init RuntimeLogger automatically for each runtime api call (#8128)
* Init `RuntimeLogger` automatically for each runtime api call This pr change the runtime api in such a way to always and automatically enable the `RuntimeLogger`. This enables the user to use `log` or `tracing` from inside the runtime to create log messages. As logging introduces some extra code and especially increases the size of the wasm blob. It is advised to disable all logging completely with `sp-api/disable-logging` when doing the wasm builds for the on-chain wasm runtime. Besides these changes, the pr also brings most of the logging found in frame to the same format "runtime::*". * Update frame/im-online/src/lib.rs Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com> * Update test-utils/runtime/Cargo.toml * Fix test * Don't use tracing in the runtime, as we don't support it :D * Fixes Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
This commit is contained in:
@@ -44,9 +44,9 @@ pub use sp_state_machine::BasicExternalities;
|
||||
pub use sp_io::{storage::root as storage_root, self};
|
||||
#[doc(hidden)]
|
||||
pub use sp_runtime::RuntimeDebug;
|
||||
#[doc(hidden)]
|
||||
pub use log;
|
||||
|
||||
#[macro_use]
|
||||
pub mod debug;
|
||||
#[macro_use]
|
||||
mod origin;
|
||||
#[macro_use]
|
||||
@@ -340,6 +340,30 @@ macro_rules! ord_parameter_types {
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out a formatted message.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```
|
||||
/// frame_support::runtime_print!("my value is {}", 3);
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! runtime_print {
|
||||
($($arg:tt)+) => {
|
||||
{
|
||||
use core::fmt::Write;
|
||||
let mut w = $crate::sp_std::Writer::default();
|
||||
let _ = core::write!(&mut w, $($arg)+);
|
||||
$crate::sp_io::misc::print_utf8(&w.inner())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Print out the debuggable type.
|
||||
pub fn debug(data: &impl sp_std::fmt::Debug) {
|
||||
runtime_print!("{:?}", data);
|
||||
}
|
||||
|
||||
#[doc(inline)]
|
||||
pub use frame_support_procedural::{
|
||||
decl_storage, construct_runtime, transactional, RuntimeDebugNoBound
|
||||
@@ -1051,7 +1075,7 @@ pub mod pallet_prelude {
|
||||
pub use frame_support::traits::GenesisBuild;
|
||||
pub use frame_support::{
|
||||
EqNoBound, PartialEqNoBound, RuntimeDebugNoBound, DebugNoBound, CloneNoBound, Twox256,
|
||||
Twox128, Blake2_256, Blake2_128, Identity, Twox64Concat, Blake2_128Concat, debug, ensure,
|
||||
Twox128, Blake2_256, Blake2_128, Identity, Twox64Concat, Blake2_128Concat, ensure,
|
||||
RuntimeDebug, storage,
|
||||
traits::{Get, Hooks, IsType, GetPalletVersion, EnsureOrigin},
|
||||
dispatch::{DispatchResultWithPostInfo, Parameter, DispatchError},
|
||||
|
||||
Reference in New Issue
Block a user