From 8f27ce443a51a4bc88e5986167736edd29e50f52 Mon Sep 17 00:00:00 2001 From: jolestar Date: Tue, 22 Jun 2021 20:02:23 +0800 Subject: [PATCH] [log] Change sync log level in test and dev chain. --- commons/logger/src/lib.rs | 2 +- network-p2p/src/lib.rs | 2 -- sync/src/sync.rs | 9 ++++++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/commons/logger/src/lib.rs b/commons/logger/src/lib.rs index 00c36c71d3..7a9b836bdd 100644 --- a/commons/logger/src/lib.rs +++ b/commons/logger/src/lib.rs @@ -29,7 +29,7 @@ pub mod structured_log; pub mod prelude { pub use crate::stacktrace; pub use crate::{sl_crit, sl_debug, sl_error, sl_info, sl_trace, sl_warn}; - pub use log::{debug, error, info, log_enabled, trace, warn, Level, LevelFilter}; + pub use log::{debug, error, info, log, log_enabled, trace, warn, Level, LevelFilter}; pub use slog::{slog_crit, slog_debug, slog_error, slog_info, slog_trace, slog_warn}; } diff --git a/network-p2p/src/lib.rs b/network-p2p/src/lib.rs index b0d468cc04..4d4c696039 100644 --- a/network-p2p/src/lib.rs +++ b/network-p2p/src/lib.rs @@ -1,8 +1,6 @@ // Copyright (c) The Starcoin Core Contributors // SPDX-License-Identifier: Apache-2.0 -#[macro_use] -extern crate log; extern crate prometheus; #[macro_use] extern crate starcoin_metrics; diff --git a/sync/src/sync.rs b/sync/src/sync.rs index 3b27e4d5e0..b1dc6c281f 100644 --- a/sync/src/sync.rs +++ b/sync/src/sync.rs @@ -127,11 +127,18 @@ impl SyncService { loop { if peer_set.is_empty() || peer_set.len() < (config.net().min_peers() as usize) { - info!( + let level = if config.net().is_dev() || config.net().is_test() { + Level::Debug + } else { + Level::Info + }; + log!( + level, "[sync]Waiting enough peers to sync, current: {:?} peers, min peers: {:?}", peer_set.len(), config.net().min_peers() ); + Delay::new(Duration::from_secs(1)).await; peer_set = network.peer_set().await?; } else {