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

Init RuntimeLogger automatically for each runtime api call #8128

Merged
merged 13 commits into from
Mar 1, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 24 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions bin/node/runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ codec = { package = "parity-scale-codec", version = "2.0.0", default-features =
serde = { version = "1.0.102", optional = true }
static_assertions = "1.1.0"
hex-literal = { version = "0.3.1", optional = true }
log = { version = "0.4.14", default-features = false }

# primitives
sp-authority-discovery = { version = "3.0.0", default-features = false, path = "../../../primitives/authority-discovery" }
Expand Down Expand Up @@ -151,6 +152,7 @@ std = [
"pallet-society/std",
"pallet-recovery/std",
"pallet-vesting/std",
"log/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
4 changes: 2 additions & 2 deletions bin/node/runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

use sp_std::prelude::*;
use frame_support::{
construct_runtime, parameter_types, debug, RuntimeDebug,
construct_runtime, parameter_types, RuntimeDebug,
weights::{
Weight, IdentityFee,
constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND}, DispatchClass,
Expand Down Expand Up @@ -804,7 +804,7 @@ impl<LocalCall> frame_system::offchain::CreateSignedTransaction<LocalCall> for R
);
let raw_payload = SignedPayload::new(call, extra)
.map_err(|e| {
debug::warn!("Unable to create signed payload: {:?}", e);
log::warn!("Unable to create signed payload: {:?}", e);
})
.ok()?;
let signature = raw_payload
Expand Down
2 changes: 2 additions & 0 deletions frame/babe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sp-session = { version = "3.0.0", default-features = false, path = "../../primit
sp-staking = { version = "3.0.0", default-features = false, path = "../../primitives/staking" }
sp-std = { version = "3.0.0", default-features = false, path = "../../primitives/std" }
sp-timestamp = { version = "3.0.0", default-features = false, path = "../../primitives/timestamp" }
log = { version = "0.4.14", default-features = false }

[dev-dependencies]
frame-benchmarking = { version = "3.0.0", path = "../benchmarking" }
Expand Down Expand Up @@ -61,5 +62,6 @@ std = [
"sp-staking/std",
"sp-std/std",
"sp-timestamp/std",
"log/std",
]
runtime-benchmarks = ["frame-benchmarking"]
22 changes: 13 additions & 9 deletions frame/babe/src/equivocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@
//! definition.
//!

use frame_support::{
debug,
traits::{Get, KeyOwnerProofSystem},
};
use frame_support::traits::{Get, KeyOwnerProofSystem};
use sp_consensus_babe::{EquivocationProof, Slot};
use sp_runtime::transaction_validity::{
InvalidTransaction, TransactionPriority, TransactionSource, TransactionValidity,
Expand Down Expand Up @@ -163,8 +160,15 @@ where
let call = Call::report_equivocation_unsigned(equivocation_proof, key_owner_proof);

match SubmitTransaction::<T, Call<T>>::submit_unsigned_transaction(call.into()) {
Ok(()) => debug::info!("Submitted BABE equivocation report."),
Err(e) => debug::error!("Error submitting equivocation report: {:?}", e),
Ok(()) => log::info!(
target: "runtime::babe",
"Submitted BABE equivocation report.",
),
Err(e) => log::error!(
target: "runtime::babe",
"Error submitting equivocation report: {:?}",
e,
),
}

Ok(())
Expand All @@ -186,9 +190,9 @@ impl<T: Config> frame_support::unsigned::ValidateUnsigned for Module<T> {
match source {
TransactionSource::Local | TransactionSource::InBlock => { /* allowed */ }
_ => {
debug::warn!(
target: "babe",
"rejecting unsigned report equivocation transaction because it is not local/in-block."
log::warn!(
target: "runtime::babe",
"rejecting unsigned report equivocation transaction because it is not local/in-block.",
);

return InvalidTransaction::Call.into();
Expand Down
2 changes: 2 additions & 0 deletions frame/balances/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ sp-runtime = { version = "3.0.0", default-features = false, path = "../../primit
frame-benchmarking = { version = "3.0.0", default-features = false, path = "../benchmarking", optional = true }
frame-support = { version = "3.0.0", default-features = false, path = "../support" }
frame-system = { version = "3.0.0", default-features = false, path = "../system" }
log = { version = "0.4.14", default-features = false }

[dev-dependencies]
sp-io = { version = "3.0.0", path = "../../primitives/io" }
Expand All @@ -36,5 +37,6 @@ std = [
"frame-benchmarking/std",
"frame-support/std",
"frame-system/std",
"log/std",
]
runtime-benchmarks = ["frame-benchmarking"]
6 changes: 4 additions & 2 deletions frame/balances/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
/// Update the account entry for `who`, given the locks.
fn update_locks(who: &T::AccountId, locks: &[BalanceLock<T::Balance>]) {
if locks.len() as u32 > T::MaxLocks::get() {
frame_support::debug::warn!(
log::warn!(
target: "runtime::balances",
"Warning: A user has more currency locks than expected. \
A runtime configuration adjustment may be needed."
);
Expand Down Expand Up @@ -749,7 +750,8 @@ impl<T: Config<I>, I: 'static> Pallet<T, I> {
// No providers for the locks. This is impossible under normal circumstances
// since the funds that are under the lock will themselves be stored in the
// account and therefore will need a reference.
frame_support::debug::warn!(
log::warn!(
target: "runtime::balances",
"Warning: Attempt to introduce lock consumer reference, yet no providers. \
This is unexpected but should be safe."
);
Expand Down
2 changes: 2 additions & 0 deletions frame/benchmarking/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ sp-io = { version = "3.0.0", path = "../../primitives/io", default-features = fa
sp-storage = { version = "3.0.0", path = "../../primitives/storage", default-features = false }
frame-support = { version = "3.0.0", default-features = false, path = "../support" }
frame-system = { version = "3.0.0", default-features = false, path = "../system" }
log = { version = "0.4.14", default-features = false }

[dev-dependencies]
hex-literal = "0.3.1"
Expand All @@ -40,4 +41,5 @@ std = [
"frame-support/std",
"frame-system/std",
"linregress",
"log/std",
]
12 changes: 9 additions & 3 deletions frame/benchmarking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ pub use utils::*;
pub use analysis::{Analysis, BenchmarkSelector, RegressionModel};
#[doc(hidden)]
pub use sp_io::storage::root as storage_root;
#[doc(hidden)]
pub use sp_runtime::traits::Zero;
#[doc(hidden)]
pub use frame_support;
#[doc(hidden)]
pub use paste;
#[doc(hidden)]
pub use sp_storage::TrackedStorageKey;
#[doc(hidden)]
pub use log;

/// Construct pallet benchmarks for weighing dispatchables.
///
Expand Down Expand Up @@ -731,7 +737,7 @@ macro_rules! impl_benchmark {
closure_to_benchmark()?;
} else {
// Time the extrinsic logic.
frame_support::debug::trace!(
$crate::log::trace!(
target: "benchmark",
"Start Benchmark: {:?}", c
);
Expand All @@ -744,12 +750,12 @@ macro_rules! impl_benchmark {
let elapsed_extrinsic = finish_extrinsic - start_extrinsic;
// Commit the changes to get proper write count
$crate::benchmarking::commit_db();
frame_support::debug::trace!(
$crate::log::trace!(
target: "benchmark",
"End Benchmark: {} ns", elapsed_extrinsic
);
let read_write_count = $crate::benchmarking::read_write_count();
frame_support::debug::trace!(
$crate::log::trace!(
target: "benchmark",
"Read/Write Count {:?}", read_write_count
);
Expand Down
2 changes: 2 additions & 0 deletions frame/collective/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ sp-runtime = { version = "3.0.0", default-features = false, path = "../../primit
frame-benchmarking = { version = "3.0.0", default-features = false, path = "../benchmarking", optional = true }
frame-support = { version = "3.0.0", default-features = false, path = "../support" }
frame-system = { version = "3.0.0", default-features = false, path = "../system" }
tracing = { version = "0.1.22", default-features = false }

[dev-dependencies]
hex-literal = "0.3.1"
Expand All @@ -38,6 +39,7 @@ std = [
"frame-support/std",
"sp-runtime/std",
"frame-system/std",
"tracing/std",
]
runtime-benchmarks = [
"frame-benchmarking",
Expand Down
Loading