Fix logging from inside the WASM runtime (#7355)

* Fix logging from inside the WASM runtime

When using `RuntimeLogger` to log something from the runtime, we didn't
set any logging level. So, we actually did not log anything from the
runtime as logging is disabled by default. This pr fixes that by setting
the logging level to `TRACE`. It also adds a test to ensure this does
not break again ;)

* Update frame/support/src/debug.rs
This commit is contained in:
Bastian Köcher
2020-10-20 12:51:51 +02:00
committed by GitHub
parent 918a0c8077
commit 203acda659
5 changed files with 69 additions and 2 deletions
+14
View File
@@ -340,6 +340,8 @@ cfg_if! {
/// Test that ensures that we can call a function that takes multiple
/// arguments.
fn test_multiple_arguments(data: Vec<u8>, other: Vec<u8>, num: u32);
/// Traces log "Hey I'm runtime."
fn do_trace_log();
}
}
} else {
@@ -391,6 +393,8 @@ cfg_if! {
/// Test that ensures that we can call a function that takes multiple
/// arguments.
fn test_multiple_arguments(data: Vec<u8>, other: Vec<u8>, num: u32);
/// Traces log "Hey I'm runtime."
fn do_trace_log();
}
}
}
@@ -698,6 +702,11 @@ cfg_if! {
assert_eq!(&data[..], &other[..]);
assert_eq!(data.len(), num as usize);
}
fn do_trace_log() {
frame_support::debug::RuntimeLogger::init();
frame_support::debug::trace!("Hey I'm runtime");
}
}
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {
@@ -944,6 +953,11 @@ cfg_if! {
assert_eq!(&data[..], &other[..]);
assert_eq!(data.len(), num as usize);
}
fn do_trace_log() {
frame_support::debug::RuntimeLogger::init();
frame_support::debug::trace!("Hey I'm runtime");
}
}
impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {