diff --git a/substrate/frame/assets/src/lib.rs b/substrate/frame/assets/src/lib.rs index 1853ef75f5..93e416c3be 100644 --- a/substrate/frame/assets/src/lib.rs +++ b/substrate/frame/assets/src/lib.rs @@ -175,6 +175,7 @@ pub use pallet::*; pub use weights::WeightInfo; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; +const LOG_TARGET: &str = "runtime::assets"; /// Trait with callbacks that are executed after successfull asset creation or destruction. pub trait AssetsCallback { diff --git a/substrate/frame/assets/src/migration.rs b/substrate/frame/assets/src/migration.rs index 89f8d39a90..9f8905ceff 100644 --- a/substrate/frame/assets/src/migration.rs +++ b/substrate/frame/assets/src/migration.rs @@ -75,10 +75,18 @@ pub mod v1 { Some(old_value.migrate_to_v1()) }); current_version.put::>(); - log::info!(target: "runtime::assets", "Upgraded {} pools, storage to version {:?}", translated, current_version); + log::info!( + target: LOG_TARGET, + "Upgraded {} pools, storage to version {:?}", + translated, + current_version + ); T::DbWeight::get().reads_writes(translated + 1, translated + 1) } else { - log::info!(target: "runtime::assets", "Migration did not execute. This probably should be removed"); + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); T::DbWeight::get().reads(1) } } diff --git a/substrate/frame/balances/src/lib.rs b/substrate/frame/balances/src/lib.rs index 57f76b1ff6..99d77a3e73 100644 --- a/substrate/frame/balances/src/lib.rs +++ b/substrate/frame/balances/src/lib.rs @@ -193,6 +193,8 @@ pub use weights::WeightInfo; pub use pallet::*; +const LOG_TARGET: &str = "runtime::balances"; + type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; #[frame_support::pallet] @@ -950,7 +952,7 @@ impl, I: 'static> Pallet { if locks.len() as u32 > T::MaxLocks::get() { log::warn!( - target: "runtime::balances", + target: LOG_TARGET, "Warning: A user has more currency locks than expected. \ A runtime configuration adjustment may be needed." ); @@ -985,7 +987,7 @@ impl, I: 'static> Pallet { // since the funds that are under the lock will themselves be stored in the // account and therefore will need a reference. log::warn!( - target: "runtime::balances", + target: LOG_TARGET, "Warning: Attempt to introduce lock consumer reference, yet no providers. \ This is unexpected but should be safe." ); diff --git a/substrate/frame/balances/src/migration.rs b/substrate/frame/balances/src/migration.rs index b660ec9fd3..80d1bcd35b 100644 --- a/substrate/frame/balances/src/migration.rs +++ b/substrate/frame/balances/src/migration.rs @@ -40,10 +40,13 @@ fn migrate_v0_to_v1, I: 'static>(accounts: &[T::AccountId]) -> Weig // Set storage version to `1`. StorageVersion::new(1).put::>(); - log::info!(target: "runtime::balances", "Storage to version 1"); + log::info!(target: LOG_TARGET, "Storage to version 1"); T::DbWeight::get().reads_writes(2 + accounts.len() as u64, 3) } else { - log::info!(target: "runtime::balances", "Migration did not execute. This probably should be removed"); + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); T::DbWeight::get().reads(1) } } @@ -87,10 +90,13 @@ impl, I: 'static> OnRuntimeUpgrade for ResetInactive { // Set storage version to `0`. StorageVersion::new(0).put::>(); - log::info!(target: "runtime::balances", "Storage to version 0"); + log::info!(target: LOG_TARGET, "Storage to version 0"); T::DbWeight::get().reads_writes(1, 2) } else { - log::info!(target: "runtime::balances", "Migration did not execute. This probably should be removed"); + log::info!( + target: LOG_TARGET, + "Migration did not execute. This probably should be removed" + ); T::DbWeight::get().reads(1) } } diff --git a/substrate/frame/collective/src/lib.rs b/substrate/frame/collective/src/lib.rs index c522b71891..0fe05dbb01 100644 --- a/substrate/frame/collective/src/lib.rs +++ b/substrate/frame/collective/src/lib.rs @@ -71,6 +71,8 @@ pub mod weights; pub use pallet::*; pub use weights::WeightInfo; +const LOG_TARGET: &str = "runtime::collective"; + /// Simple index type for proposal counting. pub type ProposalIndex = u32; @@ -390,7 +392,7 @@ pub mod pallet { ensure_root(origin)?; if new_members.len() > T::MaxMembers::get() as usize { log::error!( - target: "runtime::collective", + target: LOG_TARGET, "New members count ({}) exceeds maximum amount of members expected ({}).", new_members.len(), T::MaxMembers::get(), @@ -400,7 +402,7 @@ pub mod pallet { let old = Members::::get(); if old.len() > old_count as usize { log::warn!( - target: "runtime::collective", + target: LOG_TARGET, "Wrong count used to estimate set_members weight. expected ({}) vs actual ({})", old_count, old.len(), @@ -1040,7 +1042,7 @@ impl, I: 'static> ChangeMembers for Pallet { ) { if new.len() > T::MaxMembers::get() as usize { log::error!( - target: "runtime::collective", + target: LOG_TARGET, "New members count ({}) exceeds maximum amount of members expected ({}).", new.len(), T::MaxMembers::get(), diff --git a/substrate/frame/collective/src/migrations/v4.rs b/substrate/frame/collective/src/migrations/v4.rs index 483c3f9fa9..2756b3fd15 100644 --- a/substrate/frame/collective/src/migrations/v4.rs +++ b/substrate/frame/collective/src/migrations/v4.rs @@ -17,6 +17,7 @@ use sp_io::hashing::twox_128; +use super::super::LOG_TARGET; use frame_support::{ traits::{ Get, GetStorageVersion, PalletInfoAccess, StorageVersion, @@ -42,7 +43,7 @@ pub fn migrate::on_chain_storage_version(); log::info!( - target: "runtime::collective", + target: LOG_TARGET, "Running migration to v4 for collective with storage version {:?}", on_chain_storage_version, ); @@ -66,7 +67,7 @@ pub fn migrate::BlockWeights::get().max_block } else { log::warn!( - target: "runtime::collective", + target: LOG_TARGET, "Attempted to apply migration to v4 but failed because storage version is {:?}", on_chain_storage_version, ); @@ -138,7 +139,7 @@ pub fn post_migrate>(old_ fn log_migration(stage: &str, old_pallet_name: &str, new_pallet_name: &str) { log::info!( - target: "runtime::collective", + target: LOG_TARGET, "{}, prefix: '{}' ==> '{}'", stage, old_pallet_name, diff --git a/substrate/frame/elections-phragmen/src/lib.rs b/substrate/frame/elections-phragmen/src/lib.rs index 1cfdc25fd9..1a020adb28 100644 --- a/substrate/frame/elections-phragmen/src/lib.rs +++ b/substrate/frame/elections-phragmen/src/lib.rs @@ -122,6 +122,8 @@ pub use weights::WeightInfo; /// All migrations. pub mod migrations; +const LOG_TARGET: &str = "runtime::elections-phragmen"; + /// The maximum votes allowed per voter. pub const MAXIMUM_VOTE: usize = 16; @@ -789,10 +791,7 @@ impl Pallet { } else { // overlap. This can never happen. If so, it seems like our intended replacement // is already a member, so not much more to do. - log::error!( - target: "runtime::elections-phragmen", - "A member seems to also be a runner-up.", - ); + log::error!(target: LOG_TARGET, "A member seems to also be a runner-up."); } next_best }); @@ -939,7 +938,7 @@ impl Pallet { Ok(_) => (), Err(_) => { log::error!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "Failed to run election. Number of voters exceeded", ); Self::deposit_event(Event::ElectionError); @@ -1103,11 +1102,7 @@ impl Pallet { >::mutate(|v| *v += 1); }) .map_err(|e| { - log::error!( - target: "runtime::elections-phragmen", - "Failed to run election [{:?}].", - e, - ); + log::error!(target: LOG_TARGET, "Failed to run election [{:?}].", e,); Self::deposit_event(Event::ElectionError); }); diff --git a/substrate/frame/elections-phragmen/src/migrations/v3.rs b/substrate/frame/elections-phragmen/src/migrations/v3.rs index 9ec9c6e7ee..e48cd6c1a8 100644 --- a/substrate/frame/elections-phragmen/src/migrations/v3.rs +++ b/substrate/frame/elections-phragmen/src/migrations/v3.rs @@ -17,6 +17,7 @@ //! Migrations to version [`3.0.0`], as denoted by the changelog. +use super::super::LOG_TARGET; use crate::{Config, Pallet}; use codec::{Decode, Encode, FullCodec}; use frame_support::{ @@ -88,7 +89,7 @@ pub fn apply( ) -> Weight { let storage_version = StorageVersion::get::>(); log::info!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "Running migration for elections-phragmen with storage version {:?}", storage_version, ); @@ -104,7 +105,7 @@ pub fn apply( Weight::MAX } else { log::warn!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "Attempted to apply migration to V3 but failed because storage version is {:?}", storage_version, ); @@ -118,22 +119,14 @@ pub fn migrate_voters_to_recorded_deposit(old_deposit: V:: Some(Voter { votes, stake, deposit: old_deposit }) }); - log::info!( - target: "runtime::elections-phragmen", - "migrated {} voter accounts.", - >::iter().count(), - ); + log::info!(target: LOG_TARGET, "migrated {} voter accounts.", >::iter().count()); } /// Migrate all candidates to recorded deposit. pub fn migrate_candidates_to_recorded_deposit(old_deposit: V::Balance) { let _ = >::translate::, _>(|maybe_old_candidates| { maybe_old_candidates.map(|old_candidates| { - log::info!( - target: "runtime::elections-phragmen", - "migrated {} candidate accounts.", - old_candidates.len(), - ); + log::info!(target: LOG_TARGET, "migrated {} candidate accounts.", old_candidates.len()); old_candidates.into_iter().map(|c| (c, old_deposit)).collect::>() }) }); @@ -143,11 +136,7 @@ pub fn migrate_candidates_to_recorded_deposit(old_deposit: pub fn migrate_members_to_recorded_deposit(old_deposit: V::Balance) { let _ = >::translate::, _>(|maybe_old_members| { maybe_old_members.map(|old_members| { - log::info!( - target: "runtime::elections-phragmen", - "migrated {} member accounts.", - old_members.len(), - ); + log::info!(target: LOG_TARGET, "migrated {} member accounts.", old_members.len()); old_members .into_iter() .map(|(who, stake)| SeatHolder { who, stake, deposit: old_deposit }) @@ -162,7 +151,7 @@ pub fn migrate_runners_up_to_recorded_deposit(old_deposit: |maybe_old_runners_up| { maybe_old_runners_up.map(|old_runners_up| { log::info!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "migrated {} runner-up accounts.", old_runners_up.len(), ); diff --git a/substrate/frame/elections-phragmen/src/migrations/v4.rs b/substrate/frame/elections-phragmen/src/migrations/v4.rs index 76ef630706..535a9fb820 100644 --- a/substrate/frame/elections-phragmen/src/migrations/v4.rs +++ b/substrate/frame/elections-phragmen/src/migrations/v4.rs @@ -17,6 +17,7 @@ //! Migrations to version [`4.0.0`], as denoted by the changelog. +use super::super::LOG_TARGET; use frame_support::{ traits::{Get, StorageVersion}, weights::Weight, @@ -35,14 +36,14 @@ pub const OLD_PREFIX: &[u8] = b"PhragmenElection"; pub fn migrate>(new_pallet_name: N) -> Weight { if new_pallet_name.as_ref().as_bytes() == OLD_PREFIX { log::info!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "New pallet name is equal to the old prefix. No migration needs to be done.", ); return Weight::zero() } let storage_version = StorageVersion::get::>(); log::info!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "Running migration to v4 for elections-phragmen with storage version {:?}", storage_version, ); @@ -59,7 +60,7 @@ pub fn migrate>(new_pallet_name: N) -> Weight { ::BlockWeights::get().max_block } else { log::warn!( - target: "runtime::elections-phragmen", + target: LOG_TARGET, "Attempted to apply migration to v4 but failed because storage version is {:?}", storage_version, ); diff --git a/substrate/frame/membership/src/lib.rs b/substrate/frame/membership/src/lib.rs index 8531af120e..934abb996d 100644 --- a/substrate/frame/membership/src/lib.rs +++ b/substrate/frame/membership/src/lib.rs @@ -36,6 +36,8 @@ pub mod weights; pub use pallet::*; pub use weights::WeightInfo; +const LOG_TARGET: &str = "runtime::membership"; + type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; #[frame_support::pallet] diff --git a/substrate/frame/membership/src/migrations/v4.rs b/substrate/frame/membership/src/migrations/v4.rs index 5b8735aa2b..cbc58cd6ae 100644 --- a/substrate/frame/membership/src/migrations/v4.rs +++ b/substrate/frame/membership/src/migrations/v4.rs @@ -15,6 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +use super::super::LOG_TARGET; use sp_io::hashing::twox_128; use frame_support::{ @@ -43,7 +44,7 @@ pub fn migrate::on_chain_storage_version(); log::info!( - target: "runtime::membership", + target: LOG_TARGET, "Running migration to v4 for membership with storage version {:?}", on_chain_storage_version, ); @@ -67,7 +68,7 @@ pub fn migrate::BlockWeights::get().max_block } else { log::warn!( - target: "runtime::membership", + target: LOG_TARGET, "Attempted to apply migration to v4 but failed because storage version is {:?}", on_chain_storage_version, ); @@ -139,7 +140,7 @@ pub fn post_migrate>(old_pallet_name: N, new fn log_migration(stage: &str, old_pallet_name: &str, new_pallet_name: &str) { log::info!( - target: "runtime::membership", + target: LOG_TARGET, "{}, prefix: '{}' ==> '{}'", stage, old_pallet_name, diff --git a/substrate/frame/session/src/migrations/v1.rs b/substrate/frame/session/src/migrations/v1.rs index c0dce422fe..6689ca7299 100644 --- a/substrate/frame/session/src/migrations/v1.rs +++ b/substrate/frame/session/src/migrations/v1.rs @@ -29,6 +29,8 @@ use frame_support::{ use crate::historical as pallet_session_historical; +const LOG_TARGET: &str = "runtime::session_historical"; + const OLD_PREFIX: &str = "Session"; /// Migrate the entire storage of this pallet to a new prefix. @@ -44,7 +46,7 @@ pub fn migrate::on_chain_storage_version(); log::info!( - target: "runtime::session_historical", + target: LOG_TARGET, "Running migration to v1 for session_historical with storage version {:?}", on_chain_storage_version, ); @@ -78,7 +80,7 @@ pub fn migrate::BlockWeights::get().max_block } else { log::warn!( - target: "runtime::session_historical", + target: LOG_TARGET, "Attempted to apply migration to v1 but failed because storage version is {:?}", on_chain_storage_version, ); @@ -184,7 +186,7 @@ pub fn post_migrate< fn log_migration(stage: &str, storage_prefix: &[u8], old_pallet_name: &str, new_pallet_name: &str) { log::info!( - target: "runtime::session_historical", + target: LOG_TARGET, "{} prefix of storage '{}': '{}' ==> '{}'", stage, str::from_utf8(storage_prefix).unwrap_or(""), diff --git a/substrate/frame/system/src/lib.rs b/substrate/frame/system/src/lib.rs index c790d33add..3909b1e9c5 100644 --- a/substrate/frame/system/src/lib.rs +++ b/substrate/frame/system/src/lib.rs @@ -129,6 +129,8 @@ pub use extensions::check_mortality::CheckMortality as CheckEra; pub use frame_support::dispatch::RawOrigin; pub use weights::WeightInfo; +const LOG_TARGET: &str = "runtime::system"; + /// Compute the trie root of a list of extrinsics. /// /// The merkle proof is using the same trie as runtime state with @@ -1075,7 +1077,7 @@ impl Pallet { if account.providers == 0 { // Logic error - cannot decrement beyond zero. log::error!( - target: "runtime::system", + target: LOG_TARGET, "Logic error: Unexpected underflow in reducing provider", ); account.providers = 1; @@ -1101,7 +1103,7 @@ impl Pallet { } } else { log::error!( - target: "runtime::system", + target: LOG_TARGET, "Logic error: Account already dead when reducing provider", ); Ok(DecRefStatus::Reaped) @@ -1133,7 +1135,7 @@ impl Pallet { if account.sufficients == 0 { // Logic error - cannot decrement beyond zero. log::error!( - target: "runtime::system", + target: LOG_TARGET, "Logic error: Unexpected underflow in reducing sufficients", ); } @@ -1150,7 +1152,7 @@ impl Pallet { } } else { log::error!( - target: "runtime::system", + target: LOG_TARGET, "Logic error: Account already dead when reducing provider", ); DecRefStatus::Reaped @@ -1215,7 +1217,7 @@ impl Pallet { a.consumers -= 1; } else { log::error!( - target: "runtime::system", + target: LOG_TARGET, "Logic error: Unexpected underflow in reducing consumer", ); } @@ -1337,7 +1339,7 @@ impl Pallet { /// resulting header for this block. pub fn finalize() -> T::Header { log::debug!( - target: "runtime::system", + target: LOG_TARGET, "[{:?}] {} extrinsics, length: {} (normal {}%, op: {}%, mandatory {}%) / normal weight:\ {} ({}%) op weight {} ({}%) / mandatory weight {} ({}%)", Self::block_number(), @@ -1547,7 +1549,7 @@ impl Pallet { Ok(_) => Event::ExtrinsicSuccess { dispatch_info: info }, Err(err) => { log::trace!( - target: "runtime::system", + target: LOG_TARGET, "Extrinsic failed at block({:?}): {:?}", Self::block_number(), err, diff --git a/substrate/frame/system/src/migrations/mod.rs b/substrate/frame/system/src/migrations/mod.rs index 15746d7376..90b88de1ab 100644 --- a/substrate/frame/system/src/migrations/mod.rs +++ b/substrate/frame/system/src/migrations/mod.rs @@ -17,6 +17,7 @@ //! Migrate the reference counting state. +use super::LOG_TARGET; use crate::{Config, Pallet}; use codec::{Decode, Encode, FullCodec}; use frame_support::{ @@ -75,7 +76,7 @@ pub fn migrate_from_single_u8_to_triple_ref_count() -> Wei Some(AccountInfo { nonce, consumers: rc as RefCount, providers: 1, sufficients: 0, data }) }); log::info!( - target: "runtime::system", + target: LOG_TARGET, "Applied migration from single u8 to triple reference counting to {:?} elements.", translated ); @@ -94,7 +95,7 @@ pub fn migrate_from_single_to_triple_ref_count() -> Weight }, ); log::info!( - target: "runtime::system", + target: LOG_TARGET, "Applied migration from single to triple reference counting to {:?} elements.", translated ); @@ -112,7 +113,7 @@ pub fn migrate_from_dual_to_triple_ref_count() -> Weight { }, ); log::info!( - target: "runtime::system", + target: LOG_TARGET, "Applied migration from dual to triple reference counting to {:?} elements.", translated ); diff --git a/substrate/frame/tips/src/lib.rs b/substrate/frame/tips/src/lib.rs index dd9ebc9813..43002c7b5f 100644 --- a/substrate/frame/tips/src/lib.rs +++ b/substrate/frame/tips/src/lib.rs @@ -78,6 +78,8 @@ use frame_support::{ pub use pallet::*; pub use weights::WeightInfo; +const LOG_TARGET: &str = "runtime::tips"; + pub type BalanceOf = pallet_treasury::BalanceOf; pub type NegativeImbalanceOf = pallet_treasury::NegativeImbalanceOf; type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; diff --git a/substrate/frame/tips/src/migrations/v4.rs b/substrate/frame/tips/src/migrations/v4.rs index 5e10fa7dd2..0107e96a41 100644 --- a/substrate/frame/tips/src/migrations/v4.rs +++ b/substrate/frame/tips/src/migrations/v4.rs @@ -18,6 +18,7 @@ use sp_io::hashing::twox_128; use sp_std::str; +use super::super::LOG_TARGET; use frame_support::{ storage::StoragePrefixedMap, traits::{ @@ -46,7 +47,7 @@ pub fn migrate::on_chain_storage_version(); log::info!( - target: "runtime::tips", + target: LOG_TARGET, "Running migration to v4 for tips with storage version {:?}", on_chain_storage_version, ); @@ -80,7 +81,7 @@ pub fn migrate::BlockWeights::get().max_block } else { log::warn!( - target: "runtime::tips", + target: LOG_TARGET, "Attempted to apply migration to v4 but failed because storage version is {:?}", on_chain_storage_version, ); @@ -185,7 +186,7 @@ pub fn post_migrate< fn log_migration(stage: &str, storage_prefix: &[u8], old_pallet_name: &str, new_pallet_name: &str) { log::info!( - target: "runtime::tips", + target: LOG_TARGET, "{} prefix of storage '{}': '{}' ==> '{}'", stage, str::from_utf8(storage_prefix).unwrap_or(""), diff --git a/substrate/frame/uniques/src/lib.rs b/substrate/frame/uniques/src/lib.rs index 6b21477be4..da0f0e0560 100644 --- a/substrate/frame/uniques/src/lib.rs +++ b/substrate/frame/uniques/src/lib.rs @@ -60,6 +60,8 @@ pub use pallet::*; pub use types::*; pub use weights::WeightInfo; +const LOG_TARGET: &str = "runtime::uniques"; + type AccountIdLookupOf = <::Lookup as StaticLookup>::Source; #[frame_support::pallet] diff --git a/substrate/frame/uniques/src/migration.rs b/substrate/frame/uniques/src/migration.rs index 8a2a0ef808..fd98c030d7 100644 --- a/substrate/frame/uniques/src/migration.rs +++ b/substrate/frame/uniques/src/migration.rs @@ -24,7 +24,7 @@ pub fn migrate_to_v1, I: 'static, P: GetStorageVersion + PalletInfo ) -> frame_support::weights::Weight { let on_chain_storage_version =

::on_chain_storage_version(); log::info!( - target: "runtime::uniques", + target: LOG_TARGET, "Running migration storage v1 for uniques with storage version {:?}", on_chain_storage_version, ); @@ -37,7 +37,7 @@ pub fn migrate_to_v1, I: 'static, P: GetStorageVersion + PalletInfo } StorageVersion::new(1).put::

(); log::info!( - target: "runtime::uniques", + target: LOG_TARGET, "Running migration storage v1 for uniques with storage version {:?} was complete", on_chain_storage_version, ); @@ -45,7 +45,7 @@ pub fn migrate_to_v1, I: 'static, P: GetStorageVersion + PalletInfo T::DbWeight::get().reads_writes(count as u64 + 1, count as u64 + 1) } else { log::warn!( - target: "runtime::uniques", + target: LOG_TARGET, "Attempted to apply migration to v1 but failed because storage version is {:?}", on_chain_storage_version, );