2

In the Substrate documentation here https://docs.substrate.io/test/debug/ it says we can use Rust's Logging API crate, for example as follows in a pallet:

Cargo.toml

[dependencies]
frame-support = { version = "4.0.0-dev", default-features = false, git = "https://github.com/paritytech/substrate.git", "branch" = "polkadot-v0.9.36" }
log = "0.4.17"

lib.rs

use log::{debug, error, info, trace, warn};
...
info!("logging");

However, the Substrate documentation does not mention we may alternatively use frame_support::log instead, for example as follows in a pallet:

use frame_support::log::{debug, error, info, trace, warn};
...
info!("logging");

Substrate uses Rust's Logging API crate almost everywhere throughout the codebase, but only uses frame_support::log in a few places like Frame Executive, for example here

Why doesn't Substrate only use Rust's Logging API crate? Why does it also need and use frame_support::log? Should Substrate developers only use Rust's Logging API crate or frame_support::log or their choice of either of them?

1 Answer 1

1

Because different contributor has different knowledge of Substrate or Rust.

I use frame_support::log everywhere in my project. Because I know there is a pub use in the frame-support, and I also don't want to modify my toml file.


It is just like someone importing DispatchResult from the frame-support and someone importing it from the sp-runtime.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.