Skip to content

Commit

Permalink
EXC-1131 Bitcoin: Improvements to logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ielashi committed Jul 6, 2022
1 parent 2a6f5d8 commit 901226d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 9 additions & 3 deletions rs/bitcoin/canister/src/heartbeat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use ic_btc_types_internal::{
BitcoinAdapterRequestWrapper, BitcoinAdapterResponseWrapper, Block, GetSuccessorsRequest,
Transaction,
};
use ic_logger::{debug, error, ReplicaLogger};
use ic_logger::{debug, error, trace, ReplicaLogger};
use ic_registry_subnet_features::{BitcoinFeature, BitcoinFeatureStatus};
use ic_replicated_state::bitcoin_state::{
BitcoinState as ReplicatedBitcoinState, BitcoinStateError,
Expand Down Expand Up @@ -37,7 +37,11 @@ impl BitcoinCanister {
let mut state: State = State::from(bitcoin_state);

// Process all incoming responses from the adapter.
let previous_height = store::main_chain_height(&state);
let height = process_adapter_responses(&mut state, &self.log);
if height != previous_height {
debug!(self.log, "New Bitcoin tip height: {}", height);
}

match bitcoin_feature.status {
BitcoinFeatureStatus::Enabled | BitcoinFeatureStatus::Syncing => {
Expand Down Expand Up @@ -104,9 +108,11 @@ fn process_adapter_responses(state: &mut State, log: &ReplicaLogger) -> u32 {
.iter()
.map(|x| to_btc_block(x).block_hash())
.collect();
debug!(
trace!(
log,
"Received new blocks: {:?}, next headers {:?}", block_hashes, r.next
"Received new blocks: {:?}, next headers {:?}",
block_hashes,
r.next
);
for block in r.blocks.into_iter() {
let btc_block = to_btc_block(&block);
Expand Down
7 changes: 7 additions & 0 deletions rs/starter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ struct CliArgs {
ignore_case = true)]
log_level: Option<String>,

/// Debug overrides to show debug logs for certain components.
#[clap(long = "debug-overrides", multiple_values(true))]
debug_overrides: Vec<String>,

/// Metrics port. Default is None, i.e. periodically dump metrics on stdout.
#[clap(long = "metrics-port")]
metrics_port: Option<u16>,
Expand Down Expand Up @@ -512,6 +516,7 @@ impl CliArgs {
replica_path,
replica_version,
log_level,
debug_overrides: self.debug_overrides.clone(),
cargo_bin,
cargo_opts,
state_dir,
Expand Down Expand Up @@ -621,6 +626,7 @@ struct ValidatedConfig {
replica_path: Option<PathBuf>,
replica_version: String,
log_level: slog::Level,
debug_overrides: Vec<String>,
cargo_bin: String,
cargo_opts: String,
state_dir: PathBuf,
Expand Down Expand Up @@ -677,6 +683,7 @@ impl ValidatedConfig {
let logger_config = LoggerConfig {
node_id: NODE_INDEX,
level: self.log_level,
debug_overrides: self.debug_overrides.clone(),
..LoggerConfig::default()
};
let logger = Some(logger_config);
Expand Down

0 comments on commit 901226d

Please sign in to comment.