Skip to content

Commit

Permalink
node: demote noisy warnings to debug (#1518)
Browse files Browse the repository at this point in the history
* node: demote noisy warnings to debug

* node: demote noisy warnings to debug

* node: demote noisy warnings to debug

* cargo: run fmt --all

* forest/daemon: escalate incorrect password to error
  • Loading branch information
q9f authored Mar 31, 2022
1 parent 003308a commit e35099f
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 46 deletions.
16 changes: 0 additions & 16 deletions Cargo.lock

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

14 changes: 7 additions & 7 deletions blockchain/chain_sync/src/chain_muxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ where
match network.hello_request(peer_id, request).await {
Ok(response) => response,
Err(e) => {
error!("{}", e);
debug!("Hello request failed: {}", e);
return;
}
};
Expand Down Expand Up @@ -381,7 +381,7 @@ where
{
Ok(tipset) => tipset,
Err(why) => {
error!("Querying full tipset failed: {}", why);
debug!("Querying full tipset failed: {}", why);
return Err(why);
}
};
Expand Down Expand Up @@ -497,7 +497,7 @@ where
let event = match p2p_messages.recv().await {
Ok(event) => event,
Err(why) => {
error!("Receiving event from p2p event stream failed: {}", why);
debug!("Receiving event from p2p event stream failed: {}", why);
return Err(ChainMuxerError::P2PEventStreamReceive(why.to_string()));
}
};
Expand Down Expand Up @@ -612,7 +612,7 @@ where
let event = match p2p_messages.recv().await {
Ok(event) => event,
Err(why) => {
error!("Receiving event from p2p event stream failed: {}", why);
debug!("Receiving event from p2p event stream failed: {}", why);
return Err(ChainMuxerError::P2PEventStreamReceive(why.to_string()));
}
};
Expand Down Expand Up @@ -702,15 +702,15 @@ where
// If a tipset has been provided, pass it to the tipset processor
if let Some(tipset) = tipset_opt {
if let Err(why) = tipset_sender.send(Arc::new(tipset.into_tipset())).await {
error!("Sending tipset to TipsetProcessor failed: {}", why);
debug!("Sending tipset to TipsetProcessor failed: {}", why);
return Err(ChainMuxerError::TipsetChannelSend(why.to_string()));
};
}
loop {
let event = match p2p_messages.recv().await {
Ok(event) => event,
Err(why) => {
error!("Receiving event from p2p event stream failed: {}", why);
debug!("Receiving event from p2p event stream failed: {}", why);
return Err(ChainMuxerError::P2PEventStreamReceive(why.to_string()));
}
};
Expand Down Expand Up @@ -748,7 +748,7 @@ where
}

if let Err(why) = tipset_sender.send(Arc::new(tipset.into_tipset())).await {
error!("Sending tipset to TipsetProcessor failed: {}", why);
debug!("Sending tipset to TipsetProcessor failed: {}", why);
return Err(ChainMuxerError::TipsetChannelSend(why.to_string()));
};
}
Expand Down
2 changes: 1 addition & 1 deletion blockchain/chain_sync/src/network_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ where
}
},
Err(e) => {
warn!("Failed chain_exchange request to peer {:?}: {}", p, e);
debug!("Failed chain_exchange request to peer {:?}: {}", p, e);
continue;
}
}
Expand Down
18 changes: 9 additions & 9 deletions forest/src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use byte_unit::Byte;
use directories::ProjectDirs;
use fil_types::FILECOIN_PRECISION;
use jsonrpc_v2::Error as JsonRpcError;
use log::{info, warn};
use log::{error, info, warn};
use num_bigint::BigInt;
use rug::float::ParseFloatError;
use rug::Float;
Expand Down Expand Up @@ -219,7 +219,7 @@ impl CliOpts {
fn find_default_config() -> Option<Config> {
if let Ok(config_file) = std::env::var("FOREST_CONFIG_PATH") {
info!(
"FOREST_CONFIG_PATH is set! Using configuration at {}",
"FOREST_CONFIG_PATH detected, using configuration at {}",
config_file
);
let path = PathBuf::from(config_file);
Expand All @@ -232,12 +232,12 @@ fn find_default_config() -> Option<Config> {
let mut config_dir = dir.config_dir().to_path_buf();
config_dir.push("config.toml");
if config_dir.exists() {
info!("Found config file at {}", config_dir.display());
info!("Found a config file at {}", config_dir.display());
return read_config_or_none(config_dir);
}
}

warn!("No configuration found! Using default");
warn!("No configurations found, using defaults.");

None
}
Expand All @@ -255,7 +255,7 @@ fn read_config_or_none(path: PathBuf) -> Option<Config> {
Ok(cfg) => Some(cfg),
Err(e) => {
warn!(
"Error reading configuration, opting to default. Error was {} ",
"Error reading configuration file, opting to defaults. Error was {} ",
e
);
None
Expand All @@ -272,7 +272,7 @@ pub async fn block_until_sigint() {
ctrlc::set_handler(move || {
let prev = running.fetch_add(1, Ordering::SeqCst);
if prev == 0 {
println!("Got interrupt, shutting down...");
warn!("Got interrupt, shutting down...");
// Send sig int in channel to blocking task
if let Some(ctrlc_send) = ctrlc_send_c.try_borrow_mut().unwrap().take() {
ctrlc_send.send(()).expect("Error sending ctrl-c message");
Expand All @@ -294,11 +294,11 @@ pub(super) fn handle_rpc_err(e: JsonRpcError) {
message,
data: _,
} => {
println!("JSON RPC Error: Code: {} Message: {}", code, message);
error!("JSON RPC Error: Code: {} Message: {}", code, message);
process::exit(code as i32);
}
JsonRpcError::Provided { code, message } => {
println!("JSON RPC Error: Code: {} Message: {}", code, message);
error!("JSON RPC Error: Code: {} Message: {}", code, message);
process::exit(code as i32);
}
}
Expand All @@ -319,7 +319,7 @@ pub(super) fn to_size_string(bi: &BigInt) -> String {
/// Print an error message and exit the program with an error code
/// Used for handling high level errors such as invalid params
pub(super) fn cli_error_and_die(msg: &str, code: i32) {
println!("Error: {}", msg);
error!("Error: {}", msg);
std::process::exit(code);
}

Expand Down
14 changes: 7 additions & 7 deletions forest/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use wallet::{KeyStore, KeyStoreConfig};

use async_std::{channel::bounded, sync::RwLock, task};
use libp2p::identity::{ed25519, Keypair};
use log::{debug, info, trace, warn};
use log::{debug, error, info, trace, warn};
use rpassword::read_password;

use db::rocks::RocksDb;
Expand Down Expand Up @@ -78,7 +78,7 @@ pub(super) async fn start(config: Config) {
std::io::stdout().flush().unwrap();

if passphrase != read_password().unwrap() {
println!("Passphrases do not match. Please retry.");
error!("Passphrases do not match. Please retry.");
continue;
}
}
Expand All @@ -91,7 +91,7 @@ pub(super) async fn start(config: Config) {
match key_store_init_result {
Ok(ks) => break ks,
Err(_) => {
log::error!("Incorrect passphrase entered. Please try again.")
error!("Incorrect passphrase entered. Please try again.")
}
};
}
Expand Down Expand Up @@ -121,7 +121,7 @@ pub(super) async fn start(config: Config) {
// Print admin token
let ki = ks.get(JWT_IDENTIFIER).unwrap();
let token = create_token(ADMIN.to_owned(), ki.private_key()).unwrap();
println!("Admin token: {}", token);
info!("Admin token: {}", token);

let keystore = Arc::new(RwLock::new(ks));

Expand Down Expand Up @@ -215,7 +215,7 @@ pub(super) async fn start(config: Config) {
let keystore_rpc = Arc::clone(&keystore);
let rpc_listen = format!("127.0.0.1:{}", &config.rpc_port);
Some(task::spawn(async move {
info!("JSON RPC Endpoint at {}", &rpc_listen);
info!("JSON-RPC endpoint started at {}", &rpc_listen);
start_rpc::<_, _, FullVerifier>(
Arc::new(RPCState {
state_manager: Arc::clone(&state_manager),
Expand All @@ -234,7 +234,7 @@ pub(super) async fn start(config: Config) {
.await
}))
} else {
debug!("RPC disabled");
debug!("RPC disabled.");
None
};

Expand All @@ -254,7 +254,7 @@ pub(super) async fn start(config: Config) {
}
keystore_write.await;

info!("Forest finish shutdown");
info!("Forest finish shutdown.");
}

async fn sync_from_snapshot(config: &Config, state_manager: &Arc<StateManager<RocksDb>>) {
Expand Down
4 changes: 2 additions & 2 deletions node/forest_libp2p/src/behaviour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,10 +357,10 @@ impl NetworkBehaviourEventProcess<RequestResponseEvent<ChainExchangeRequest, Cha
// Send the sucessful response through channel out.
if let Some(tx) = tx {
if tx.send(Ok(response)).is_err() {
warn!("RPCResponse receive timed out")
debug!("RPCResponse receive timed out")
}
} else {
warn!("RPCResponse receive failed: channel not found");
debug!("RPCResponse receive failed: channel not found");
};
}
},
Expand Down
8 changes: 4 additions & 4 deletions utils/paramfetch/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use async_std::{
use blake2b_simd::{Hash, State as Blake2b};
use core::time::Duration;
use fil_types::SectorSize;
use log::{info, warn};
use log::{debug, warn};
use net_utils::FetchProgress;
use pbr::{MultiBar, Units};
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -155,7 +155,7 @@ async fn fetch_params(
multi_bar: Option<Arc<MultiBar<Stdout>>>,
) -> Result<(), Box<dyn StdError>> {
let gw = std::env::var(GATEWAY_ENV).unwrap_or_else(|_| GATEWAY.to_owned());
info!("Fetching {:?} from {}", path, gw);
debug!("Fetching {:?} from {}", path, gw);

let file = File::create(path).await?;
let mut writer = BufWriter::new(file);
Expand Down Expand Up @@ -198,7 +198,7 @@ async fn fetch_params(

async fn check_file(path: Arc<Path>, info: Arc<ParameterData>) -> Result<(), io::Error> {
if std::env::var(TRUST_PARAMS_ENV) == Ok("1".to_owned()) {
warn!("Assuming parameter files are okay. DO NOT USE IN PRODUCTION");
warn!("Assuming parameter files are okay. Do not use in production!");
return Ok(());
}

Expand All @@ -215,7 +215,7 @@ async fn check_file(path: Arc<Path>, info: Arc<ParameterData>) -> Result<(), io:
let str_sum = hash.to_hex();
let str_sum = &str_sum[..32];
if str_sum == info.digest {
info!("Parameter file {:?} is ok", path);
debug!("Parameter file {:?} is ok", path);
Ok(())
} else {
Err(io::Error::new(
Expand Down

0 comments on commit e35099f

Please sign in to comment.