Skip to content

Commit

Permalink
[log] Change sync log level in test and dev chain.
Browse files Browse the repository at this point in the history
  • Loading branch information
jolestar committed Jun 22, 2021
1 parent e4d43d1 commit 8f27ce4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion commons/logger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}

Expand Down
2 changes: 0 additions & 2 deletions network-p2p/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 8 additions & 1 deletion sync/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f27ce4

Please sign in to comment.