Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
frame-support: Use logging for printing corrupted state (#10612)
Browse files Browse the repository at this point in the history
`runtime_print!` is printed by default using `debug`, aka not being visible. With `log::error!` it
will be printed directly to the user. Production networks like Polkadot disable logging, but for
them we run special nodes that have logging enabled.
  • Loading branch information
bkchr authored Jan 8, 2022
1 parent e054309 commit 617c36e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frame/support/src/storage/child.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ pub fn get<T: Decode + Sized>(child_info: &ChildInfo, key: &[u8]) -> Option<T> {
sp_io::default_child_storage::get(storage_key, key).and_then(|v| {
Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| {
// TODO #3700: error should be handleable.
crate::runtime_print!(
"ERROR: Corrupted state in child trie at {:?}/{:?}",
log::error!(
target: "runtime::storage",
"Corrupted state in child trie at {:?}/{:?}",
storage_key,
key,
);
Expand Down
6 changes: 5 additions & 1 deletion frame/support/src/storage/unhashed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ 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.
crate::runtime_print!("ERROR: Corrupted state at {:?}", key);
log::error!(
target: "runtime::storage",
"Corrupted state at {:?}",
key,
);
None
})
})
Expand Down

0 comments on commit 617c36e

Please sign in to comment.