Skip to content

Commit 879307d

Browse files
committed
switch printing to logs.
1 parent 478220d commit 879307d

File tree

7 files changed

+11
-24
lines changed

7 files changed

+11
-24
lines changed

api/src/rest.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ impl ApiServer {
239239
};
240240

241241
let mut rt = Runtime::new()
242-
.map_err(|e| eprintln!("HTTP API server error: {}", e))
242+
.map_err(|e| error!("HTTP API server error: {}", e))
243243
.unwrap();
244244
if let Err(e) = rt.block_on(server) {
245-
eprintln!("HTTP API server error: {}", e)
245+
error!("HTTP API server error: {}", e)
246246
}
247247
})
248248
.map_err(|e| ErrorKind::Internal(format!("failed to spawn API thread. {}", e)).into())
@@ -290,10 +290,10 @@ impl ApiServer {
290290
};
291291

292292
let mut rt = Runtime::new()
293-
.map_err(|e| eprintln!("HTTP API server error: {}", e))
293+
.map_err(|e| error!("HTTP API server error: {}", e))
294294
.unwrap();
295295
if let Err(e) = rt.block_on(server) {
296-
eprintln!("HTTP API server error: {}", e)
296+
error!("HTTP API server error: {}", e)
297297
}
298298
})
299299
.map_err(|e| ErrorKind::Internal(format!("failed to spawn API thread. {}", e)).into())

core/fuzz/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn generate<W: ser::Writeable>(
4343
let dir_path = Path::new("corpus").join(target);
4444
if !dir_path.is_dir() {
4545
fs::create_dir_all(&dir_path).map_err(|e| {
46-
println!("fail: {}", e);
46+
error!("fail: {}", e);
4747
ser::Error::IOErr("can't create corpus directory".to_owned(), e.kind())
4848
})?;
4949
}

p2p/src/libp2p_connection.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub async fn run_libp2p_node(
400400
let this_peer_id = PeerId::from_public_key(id_keys.public());
401401
set_this_peer_id(&this_peer_id);
402402

403-
println!("Starting libp2p, this peer: {}", this_peer_id);
403+
warn!("Starting libp2p, this peer: {}", this_peer_id);
404404
debug_assert_eq!(this_peer_id.to_string(), onion_address.to_string());
405405

406406
// Building transport
@@ -463,7 +463,7 @@ pub async fn run_libp2p_node(
463463
/* // It is ping pong handler
464464
future::poll_fn(move |cx: &mut Context<'_>| loop {
465465
match swarm.poll_next_unpin(cx) {
466-
Poll::Ready(Some(event)) => println!("{:?}", event),
466+
Poll::Ready(Some(event)) => info!("{:?}", event),
467467
Poll::Ready(None) => return Poll::Ready(()),
468468
Poll::Pending => return Poll::Pending,
469469
}

pool/fuzz/fuzz_targets/common.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl BlockChain for ChainAdapter {
113113
// Same as from pool/tests/common.rs
114114
pub fn clean_output_dir(db_root: String) {
115115
if let Err(e) = fs::remove_dir_all(db_root) {
116-
println!("cleaning output dir failed - {:?}", e)
116+
error!("cleaning output dir failed - {:?}", e)
117117
}
118118
}
119119

servers/src/grin/server.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,6 @@ impl Server {
290290
let (onion_address, tor_secret) = if config.tor_config.tor_enabled {
291291
if !config.p2p_config.host.is_loopback() {
292292
error!("If Tor is enabled, host must be '127.0.0.1'.");
293-
println!("If Tor is enabled, host must be '127.0.0.1'.");
294293
return Err(Error::Configuration(
295294
"If Tor is enabled, host must be '127.0.0.1'.".to_owned(),
296295
));
@@ -344,13 +343,12 @@ impl Server {
344343
})?;
345344

346345
let resp = output.recv();
347-
println!("Finished with TOR");
346+
info!("Finished with TOR");
348347
let onion_address = resp.unwrap_or(None);
349348
if onion_address.is_some() {
350349
info!("Tor successfully started: resp = {:?}", onion_address);
351350
} else {
352351
error!("Tor failed to start!");
353-
println!("Failed to start tor. See log for details");
354352
std::process::exit(-1);
355353
}
356354
let secret = output.recv().map_err(|e| {
@@ -363,13 +361,11 @@ impl Server {
363361

364362
if onion_address.is_none() {
365363
error!("onion_address must be specified with external tor. Halting!");
366-
println!("onion_address must be specified with external tor. Halting!");
367364
std::process::exit(-1);
368365
}
369366
let otemp = onion_address.clone().unwrap();
370367
if otemp == "" {
371368
error!("onion_address must be specified with external tor. Halting!");
372-
println!("onion_address must be specified with external tor. Halting!");
373369
std::process::exit(-1);
374370
}
375371
info!(

src/bin/grin.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ fn real_main() -> i32 {
175175
// clean command
176176
("clean", _) => {
177177
let db_root_path = node_config.unwrap().members.unwrap().server.db_root;
178-
println!("Cleaning chain data directory: {}", db_root_path);
178+
warn!("Cleaning chain data directory: {}", db_root_path);
179179
match std::fs::remove_dir_all(db_root_path) {
180180
Ok(_) => 0,
181181
Err(_) => 1,

util/src/logger.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,6 @@ fn send_panic_to_log() {
343343
}
344344
None => error!("thread '{}' panicked at '{}'{:?}", thread, msg, backtrace),
345345
}
346-
//also print to stderr
347-
let tui_running = *TUI_RUNNING.lock();
348-
if !tui_running {
349-
let config = LOGGING_CONFIG.lock();
350-
351-
eprintln!(
352-
"Thread '{}' panicked with message:\n\"{}\"\nSee {} for further details.",
353-
thread, msg, config.log_file_path
354-
);
355-
}
346+
// Node should never print to stdout/std error because it can run without terminal access
356347
}));
357348
}

0 commit comments

Comments
 (0)