mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-27 08:07:58 +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:
@@ -40,7 +40,11 @@ pub fn get<T: Decode + Sized>(
|
||||
).and_then(|v| {
|
||||
Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| {
|
||||
// TODO #3700: error should be handleable.
|
||||
runtime_print!("ERROR: Corrupted state in child trie at {:?}/{:?}", storage_key, key);
|
||||
crate::runtime_print!(
|
||||
"ERROR: Corrupted state in child trie at {:?}/{:?}",
|
||||
storage_key,
|
||||
key,
|
||||
);
|
||||
None
|
||||
})
|
||||
})
|
||||
|
||||
@@ -393,7 +393,7 @@ impl<
|
||||
let value = match unhashed::get::<O>(&previous_key) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
crate::debug::error!("Invalid translate: fail to decode old value");
|
||||
log::error!("Invalid translate: fail to decode old value");
|
||||
continue
|
||||
},
|
||||
};
|
||||
@@ -401,7 +401,7 @@ impl<
|
||||
let key1 = match K1::decode(&mut key_material) {
|
||||
Ok(key1) => key1,
|
||||
Err(_) => {
|
||||
crate::debug::error!("Invalid translate: fail to decode key1");
|
||||
log::error!("Invalid translate: fail to decode key1");
|
||||
continue
|
||||
},
|
||||
};
|
||||
@@ -410,7 +410,7 @@ impl<
|
||||
let key2 = match K2::decode(&mut key2_material) {
|
||||
Ok(key2) => key2,
|
||||
Err(_) => {
|
||||
crate::debug::error!("Invalid translate: fail to decode key2");
|
||||
log::error!("Invalid translate: fail to decode key2");
|
||||
continue
|
||||
},
|
||||
};
|
||||
|
||||
@@ -172,7 +172,7 @@ impl<
|
||||
let value = match unhashed::get::<O>(&previous_key) {
|
||||
Some(value) => value,
|
||||
None => {
|
||||
crate::debug::error!("Invalid translate: fail to decode old value");
|
||||
log::error!("Invalid translate: fail to decode old value");
|
||||
continue
|
||||
},
|
||||
};
|
||||
@@ -181,7 +181,7 @@ impl<
|
||||
let key = match K::decode(&mut key_material) {
|
||||
Ok(key) => key,
|
||||
Err(_) => {
|
||||
crate::debug::error!("Invalid translate: fail to decode key");
|
||||
log::error!("Invalid translate: fail to decode key");
|
||||
continue
|
||||
},
|
||||
};
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
@@ -25,7 +25,7 @@ pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
|
||||
sp_io::storage::get(key).and_then(|val| {
|
||||
Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| {
|
||||
// TODO #3700: error should be handleable.
|
||||
runtime_print!("ERROR: Corrupted state at {:?}", key);
|
||||
crate::runtime_print!("ERROR: Corrupted state at {:?}", key);
|
||||
None
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user