From 617c36e0ab32cd593822d2dedacfb3d7dff9160c 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. --- frame/support/src/storage/child.rs | 5 +++-- frame/support/src/storage/unhashed.rs | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/frame/support/src/storage/child.rs b/frame/support/src/storage/child.rs index a0a673d4b0417..949df84e7e768 100644 --- a/frame/support/src/storage/child.rs +++ b/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/frame/support/src/storage/unhashed.rs b/frame/support/src/storage/unhashed.rs index 5e0b527acd132..96bccc6ae0feb 100644 --- a/frame/support/src/storage/unhashed.rs +++ b/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 }) })