From e254fd59f29034cd83266bb4ed40bd6068086d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20K=C3=B6cher?= Date: Sat, 8 Jan 2022 17:13:54 +0100 Subject: [PATCH] frame-support: Use logging for printing corrupted state (#10612) `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. --- substrate/frame/support/src/storage/child.rs | 5 +++-- substrate/frame/support/src/storage/unhashed.rs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/substrate/frame/support/src/storage/child.rs b/substrate/frame/support/src/storage/child.rs index a0a673d4b0..949df84e7e 100644 --- a/substrate/frame/support/src/storage/child.rs +++ b/substrate/frame/support/src/storage/child.rs @@ -34,8 +34,9 @@ pub fn get(child_info: &ChildInfo, key: &[u8]) -> Option { 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, ); diff --git a/substrate/frame/support/src/storage/unhashed.rs b/substrate/frame/support/src/storage/unhashed.rs index 5e0b527acd..96bccc6ae0 100644 --- a/substrate/frame/support/src/storage/unhashed.rs +++ b/substrate/frame/support/src/storage/unhashed.rs @@ -25,7 +25,11 @@ pub fn get(key: &[u8]) -> Option { 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 }) })