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

Commit

Permalink
Use tracing-based subscriber logging (#6825)
Browse files Browse the repository at this point in the history
* init_logger: switch from log-based to tracing-based and add compatibility layer

* Move tracing profiling subscriber related config realization

* sp-tracing: change profiling to be a layer instead of a subscriber

* Enable profiling layer in cli

* Change all test env_logger init to sp_tracing::try_init_simple

* Remove all local env_logger dependency

* Add missing tracing-subscriber dependency

* frame-sudo: fix tests

* frame-support: fix tests

* Fix frame/pallet and executor tests

* Fix the remaining tests

* Use subscriber's try_init as recommended by @davidbarsky

* Be explict that the tracing-log feature is needed

* Set subscriber writer to stderr

* Shorter line width

* Update cargo lock tracing version

* Fix sc_tracing crate compile

* Fix sc_authority_discovery crate test

* unremove default-features

* Leave enabled to default true

* Warn if global default cannot be set

* Fix unused import

* Remove unused PROXY_TARGET

* Change all reference from rc5 to rc6

* Change all reference of rc2 to rc6

* Fix styling

* Fix typo

* make logger init error'ing

* re-fixing the test issue

Co-authored-by: Benjamin Kampmann <ben@parity.io>
  • Loading branch information
2 people authored and bkchr committed Sep 18, 2020
1 parent 59b4668 commit 2c65036
Show file tree
Hide file tree
Showing 56 changed files with 309 additions and 320 deletions.
33 changes: 18 additions & 15 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions bin/node/bench/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sc-basic-authorship = { version = "0.8.0-rc6", path = "../../../client/basic-aut
sp-inherents = { version = "2.0.0-rc6", path = "../../../primitives/inherents" }
sp-finality-tracker = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/finality-tracker" }
sp-timestamp = { version = "2.0.0-rc6", default-features = false, path = "../../../primitives/timestamp" }
sp-tracing = { version = "2.0.0-rc6", path = "../../../primitives/tracing" }
hash-db = "0.15.2"
tempfile = "3.1.0"
fs_extra = "1"
Expand Down
2 changes: 1 addition & 1 deletion bin/node/bench/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn main() {
let opt = Opt::from_args();

if !opt.json {
sc_cli::init_logger("");
sp_tracing::try_init_simple();
}

let mut import_benchmarks = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion bin/node/rpc-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ repository = "https://github.com/paritytech/substrate/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
env_logger = "0.7.0"
futures = "0.1.29"
hyper = "0.12.35"
jsonrpc-core-client = { version = "14.2.0", default-features = false, features = ["http"] }
log = "0.4.8"
node-primitives = { version = "2.0.0-rc6", path = "../primitives" }
sp-tracing = { version = "2.0.0-rc6", path = "../../../primitives/tracing" }
sc-rpc = { version = "2.0.0-rc6", path = "../../../client/rpc" }
2 changes: 1 addition & 1 deletion bin/node/rpc-client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use jsonrpc_core_client::{
};

fn main() {
env_logger::init();
sp_tracing::try_init_simple();

rt::run(rt::lazy(|| {
let uri = "http://localhost:9933";
Expand Down
2 changes: 1 addition & 1 deletion client/authority-discovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ sp-runtime = { version = "2.0.0-rc6", path = "../../primitives/runtime" }
sp-api = { version = "2.0.0-rc6", path = "../../primitives/api" }

[dev-dependencies]
env_logger = "0.7.0"
quickcheck = "0.9.0"
sp-tracing = { version = "2.0.0-rc6", path = "../../primitives/tracing" }
sc-peerset = { version = "2.0.0-rc6", path = "../peerset" }
substrate-test-runtime-client = { version = "2.0.0-rc6", path = "../../test-utils/runtime/client"}
4 changes: 2 additions & 2 deletions client/authority-discovery/src/worker/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ fn new_registers_metrics() {

#[test]
fn triggers_dht_get_query() {
let _ = ::env_logger::try_init();
sp_tracing::try_init_simple();
let (_dht_event_tx, dht_event_rx) = channel(1000);

// Generate authority keys
Expand Down Expand Up @@ -321,7 +321,7 @@ fn triggers_dht_get_query() {

#[test]
fn publish_discover_cycle() {
let _ = ::env_logger::try_init();
sp_tracing::try_init_simple();

// Node A publishing its address.

Expand Down
4 changes: 3 additions & 1 deletion client/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
derive_more = "0.99.2"
env_logger = "0.7.0"
log = "0.4.8"
atty = "0.2.13"
regex = "1.3.4"
Expand Down Expand Up @@ -50,6 +49,9 @@ sc-tracing = { version = "2.0.0-rc6", path = "../tracing" }
chrono = "0.4.10"
parity-util-mem = { version = "0.7.0", default-features = false, features = ["primitive-types"] }
serde = "1.0.111"
tracing = "0.1.10"
tracing-log = "0.1.1"
tracing-subscriber = "0.2.10"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
rpassword = "4.0.1"
Expand Down
8 changes: 6 additions & 2 deletions client/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
Ok(self.shared_params().log_filters().join(","))
}

/// Initialize substrate. This must be done only once.
/// Initialize substrate. This must be done only once per process.
///
/// This method:
///
Expand All @@ -537,10 +537,14 @@ pub trait CliConfiguration<DCV: DefaultConfigurationValues = ()>: Sized {
/// 3. Raises the FD limit
fn init<C: SubstrateCli>(&self) -> Result<()> {
let logger_pattern = self.log_filters()?;
let tracing_receiver = self.tracing_receiver()?;
let tracing_targets = self.tracing_targets()?;

sp_panic_handler::set(&C::support_url(), &C::impl_version());

init_logger(&logger_pattern);
if let Err(e) = init_logger(&logger_pattern, tracing_receiver, tracing_targets) {
log::warn!("💬 Problem initializing global logging framework: {:}", e)
}

if let Some(new_limit) = fdlimit::raise_fd_limit() {
if new_limit < RECOMMENDED_OPEN_FILE_DESCRIPTOR_LIMIT {
Expand Down
Loading

0 comments on commit 2c65036

Please sign in to comment.