mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 09:21:04 +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:
@@ -704,8 +704,9 @@ impl<T: Config> Module<T> {
|
||||
} else {
|
||||
// overlap. This can never happen. If so, it seems like our intended replacement
|
||||
// is already a member, so not much more to do.
|
||||
frame_support::debug::error!(
|
||||
"pallet-elections-phragmen: a member seems to also be a runner-up."
|
||||
log::error!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"A member seems to also be a runner-up.",
|
||||
);
|
||||
}
|
||||
next_best
|
||||
@@ -998,7 +999,11 @@ impl<T: Config> Module<T> {
|
||||
Self::deposit_event(RawEvent::NewTerm(new_members_sorted_by_id));
|
||||
ElectionRounds::mutate(|v| *v += 1);
|
||||
}).map_err(|e| {
|
||||
frame_support::debug::error!("elections-phragmen: failed to run election [{:?}].", e);
|
||||
log::error!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"Failed to run election [{:?}].",
|
||||
e,
|
||||
);
|
||||
Self::deposit_event(RawEvent::ElectionError);
|
||||
});
|
||||
|
||||
|
||||
@@ -95,9 +95,10 @@ type Voting<T: V2ToV3> = StorageMap<__Voting, Twox64Concat, T::AccountId, Voter<
|
||||
/// with care and run at your own risk.
|
||||
pub fn apply<T: V2ToV3>(old_voter_bond: T::Balance, old_candidacy_bond: T::Balance) -> Weight {
|
||||
let maybe_storage_version = <T::Module as GetPalletVersion>::storage_version();
|
||||
frame_support::debug::info!(
|
||||
log::info!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"Running migration for elections-phragmen with storage version {:?}",
|
||||
maybe_storage_version
|
||||
maybe_storage_version,
|
||||
);
|
||||
match maybe_storage_version {
|
||||
Some(storage_version) if storage_version <= PalletVersion::new(2, 0, 0) => {
|
||||
@@ -108,9 +109,10 @@ pub fn apply<T: V2ToV3>(old_voter_bond: T::Balance, old_candidacy_bond: T::Balan
|
||||
Weight::max_value()
|
||||
}
|
||||
_ => {
|
||||
frame_support::debug::warn!(
|
||||
log::warn!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"Attempted to apply migration to V3 but failed because storage version is {:?}",
|
||||
maybe_storage_version
|
||||
maybe_storage_version,
|
||||
);
|
||||
0
|
||||
},
|
||||
@@ -129,7 +131,8 @@ pub fn migrate_voters_to_recorded_deposit<T: V2ToV3>(old_deposit: T::Balance) {
|
||||
},
|
||||
);
|
||||
|
||||
frame_support::debug::info!(
|
||||
log::info!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"migrated {} voter accounts.",
|
||||
<Voting<T>>::iter().count(),
|
||||
);
|
||||
@@ -140,9 +143,10 @@ pub fn migrate_candidates_to_recorded_deposit<T: V2ToV3>(old_deposit: T::Balance
|
||||
let _ = <Candidates<T>>::translate::<Vec<T::AccountId>, _>(
|
||||
|maybe_old_candidates| {
|
||||
maybe_old_candidates.map(|old_candidates| {
|
||||
frame_support::debug::info!(
|
||||
log::info!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"migrated {} candidate accounts.",
|
||||
old_candidates.len()
|
||||
old_candidates.len(),
|
||||
);
|
||||
old_candidates
|
||||
.into_iter()
|
||||
@@ -158,7 +162,11 @@ pub fn migrate_members_to_recorded_deposit<T: V2ToV3>(old_deposit: T::Balance) {
|
||||
let _ = <Members<T>>::translate::<Vec<(T::AccountId, T::Balance)>, _>(
|
||||
|maybe_old_members| {
|
||||
maybe_old_members.map(|old_members| {
|
||||
frame_support::debug::info!("migrated {} member accounts.", old_members.len());
|
||||
log::info!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"migrated {} member accounts.",
|
||||
old_members.len(),
|
||||
);
|
||||
old_members
|
||||
.into_iter()
|
||||
.map(|(who, stake)| SeatHolder {
|
||||
@@ -177,9 +185,10 @@ pub fn migrate_runners_up_to_recorded_deposit<T: V2ToV3>(old_deposit: T::Balance
|
||||
let _ = <RunnersUp<T>>::translate::<Vec<(T::AccountId, T::Balance)>, _>(
|
||||
|maybe_old_runners_up| {
|
||||
maybe_old_runners_up.map(|old_runners_up| {
|
||||
frame_support::debug::info!(
|
||||
log::info!(
|
||||
target: "runtime::elections-phragmen",
|
||||
"migrated {} runner-up accounts.",
|
||||
old_runners_up.len()
|
||||
old_runners_up.len(),
|
||||
);
|
||||
old_runners_up
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user