mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-28 13:17:56 +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:
@@ -69,6 +69,11 @@ pub type AuraId = sp_consensus_aura::sr25519::AuthorityId;
|
||||
#[cfg(feature = "std")]
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
pub mod wasm_binary_logging_disabled {
|
||||
include!(concat!(env!("OUT_DIR"), "/wasm_binary_logging_disabled.rs"));
|
||||
}
|
||||
|
||||
/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn wasm_binary_unwrap() -> &'static [u8] {
|
||||
@@ -76,6 +81,16 @@ pub fn wasm_binary_unwrap() -> &'static [u8] {
|
||||
supported with the flag disabled.")
|
||||
}
|
||||
|
||||
/// Wasm binary unwrapped. If built with `SKIP_WASM_BUILD`, the function panics.
|
||||
#[cfg(feature = "std")]
|
||||
pub fn wasm_binary_logging_disabled_unwrap() -> &'static [u8] {
|
||||
wasm_binary_logging_disabled::WASM_BINARY
|
||||
.expect(
|
||||
"Development wasm binary is not available. Testing is only supported with the flag \
|
||||
disabled."
|
||||
)
|
||||
}
|
||||
|
||||
/// Test runtime version.
|
||||
pub const VERSION: RuntimeVersion = RuntimeVersion {
|
||||
spec_name: create_runtime_str!("test"),
|
||||
@@ -742,8 +757,7 @@ cfg_if! {
|
||||
}
|
||||
|
||||
fn do_trace_log() {
|
||||
frame_support::debug::RuntimeLogger::init();
|
||||
frame_support::debug::trace!("Hey I'm runtime");
|
||||
log::trace!("Hey I'm runtime");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,8 +1015,7 @@ cfg_if! {
|
||||
}
|
||||
|
||||
fn do_trace_log() {
|
||||
frame_support::debug::RuntimeLogger::init();
|
||||
frame_support::debug::trace!("Hey I'm runtime");
|
||||
log::error!("Hey I'm runtime: {}", log::STATIC_MAX_LEVEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user