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:
Bastian Köcher
2021-03-01 15:29:17 +01:00
committed by GitHub
parent f2d9bb9ea6
commit 68390d4085
65 changed files with 571 additions and 422 deletions
+8 -7
View File
@@ -62,7 +62,7 @@ mod debug_helper {
let mut val = v.borrow_mut();
*val += 1;
if *val > 10 {
crate::debug::warn!(
log::warn!(
"Detected with_transaction with nest level {}. Nested usage of with_transaction is not recommended.",
*val
);
@@ -532,9 +532,9 @@ impl<T> Iterator for PrefixIterator<T> {
let raw_value = match unhashed::get_raw(&self.previous_key) {
Some(raw_value) => raw_value,
None => {
crate::debug::error!(
log::error!(
"next_key returned a key with no value at {:?}",
self.previous_key
self.previous_key,
);
continue
}
@@ -546,9 +546,10 @@ impl<T> Iterator for PrefixIterator<T> {
let item = match (self.closure)(raw_key_without_prefix, &raw_value[..]) {
Ok(item) => item,
Err(e) => {
crate::debug::error!(
log::error!(
"(key, value) failed to decode at {:?}: {:?}",
self.previous_key, e
self.previous_key,
e,
);
continue
}
@@ -628,9 +629,9 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
None => unhashed::kill(&previous_key),
},
None => {
crate::debug::error!(
log::error!(
"old key failed to decode at {:?}",
previous_key
previous_key,
);
continue
},