From c9d4bb1fd80684af5b4ac3eb6b7232222ca8060c Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 5 Apr 2020 23:29:14 -0700 Subject: [PATCH] bin/*: replace `{e,}println!`s with `log` macros May as well be consistent. --- ofborg/src/bin/build-faker.rs | 9 +++++---- ofborg/src/bin/builder.rs | 8 ++++---- ofborg/src/bin/evaluation-filter.rs | 11 ++++++----- ofborg/src/bin/github-comment-filter.rs | 11 ++++++----- ofborg/src/bin/github-comment-poster.rs | 7 ++++--- ofborg/src/bin/log-message-collector.rs | 9 +++++---- ofborg/src/bin/log-message-generator.rs | 7 ++++--- ofborg/src/bin/mass-rebuilder.rs | 13 +++++++------ ofborg/src/bin/stats.rs | 13 +++++++------ 9 files changed, 48 insertions(+), 40 deletions(-) diff --git a/ofborg/src/bin/build-faker.rs b/ofborg/src/bin/build-faker.rs index 73464a6..ad51c40 100644 --- a/ofborg/src/bin/build-faker.rs +++ b/ofborg/src/bin/build-faker.rs @@ -1,3 +1,4 @@ +use log::{info, log}; use ofborg::commentparser; use ofborg::config; use ofborg::easyamqp; @@ -11,10 +12,10 @@ fn main() { let cfg = config::load(env::args().nth(1).unwrap().as_ref()); ofborg::setup_log(); - println!("Hello, world!"); + info!("Hello, world!"); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); @@ -56,7 +57,7 @@ fn main() { } channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/builder.rs b/ofborg/src/bin/builder.rs index 3af2af1..5f964d1 100644 --- a/ofborg/src/bin/builder.rs +++ b/ofborg/src/bin/builder.rs @@ -1,5 +1,5 @@ use amqp::Basic; -use log::{log, warn}; +use log::{info, log, warn}; use ofborg::checkout; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; @@ -103,10 +103,10 @@ fn main() { ) .unwrap(); - println!("Fetching jobs from {}", &queue_name); + info!("Fetching jobs from {}", &queue_name); channel.start_consuming(); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/evaluation-filter.rs b/ofborg/src/bin/evaluation-filter.rs index 672c908..73415a3 100644 --- a/ofborg/src/bin/evaluation-filter.rs +++ b/ofborg/src/bin/evaluation-filter.rs @@ -1,4 +1,5 @@ use amqp::Basic; +use log::{info, log}; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; use ofborg::tasks; @@ -10,10 +11,10 @@ fn main() { let cfg = config::load(env::args().nth(1).unwrap().as_ref()); ofborg::setup_log(); - println!("Hello, world!"); + info!("Hello, world!"); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); @@ -84,10 +85,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/github-comment-filter.rs b/ofborg/src/bin/github-comment-filter.rs index 95badaf..d7d2ebd 100644 --- a/ofborg/src/bin/github-comment-filter.rs +++ b/ofborg/src/bin/github-comment-filter.rs @@ -1,4 +1,5 @@ use amqp::Basic; +use log::{info, log}; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; use ofborg::tasks; @@ -10,10 +11,10 @@ fn main() { let cfg = config::load(env::args().nth(1).unwrap().as_ref()); ofborg::setup_log(); - println!("Hello, world!"); + info!("Hello, world!"); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); channel @@ -85,10 +86,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/github-comment-poster.rs b/ofborg/src/bin/github-comment-poster.rs index 3f04ef2..3faf332 100644 --- a/ofborg/src/bin/github-comment-poster.rs +++ b/ofborg/src/bin/github-comment-poster.rs @@ -1,4 +1,5 @@ use amqp::Basic; +use log::{info, log}; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; use ofborg::tasks; @@ -68,10 +69,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/log-message-collector.rs b/ofborg/src/bin/log-message-collector.rs index d0864d1..6047240 100644 --- a/ofborg/src/bin/log-message-collector.rs +++ b/ofborg/src/bin/log-message-collector.rs @@ -1,3 +1,4 @@ +use log::{info, log}; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; use ofborg::tasks; @@ -11,7 +12,7 @@ fn main() { ofborg::setup_log(); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); @@ -71,10 +72,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/log-message-generator.rs b/ofborg/src/bin/log-message-generator.rs index 809d082..467d791 100644 --- a/ofborg/src/bin/log-message-generator.rs +++ b/ofborg/src/bin/log-message-generator.rs @@ -1,3 +1,4 @@ +use log::{info, log}; use ofborg::config; use ofborg::easyamqp; use ofborg::message::{buildjob, Pr, Repo}; @@ -13,9 +14,9 @@ fn main() { ofborg::setup_log(); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); - println!("About to open channel #1"); + info!("About to open channel #1"); let mut chan = session.open_channel(1).unwrap(); let mut receiver = notifyworker::ChannelNotificationReceiver::new(&mut chan, 0); @@ -39,7 +40,7 @@ fn main() { }; loop { - println!("Starting a new build simulation"); + info!("Starting a new build simulation"); let mut actions = build::JobActions::new(&cfg.nix.system, &cfg.runner.identity, &job, &mut receiver); actions.log_started(vec![], vec![]); diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index a29bd26..f074749 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -1,4 +1,5 @@ use amqp::Basic; +use log::{error, info, log}; use ofborg::checkout; use ofborg::config; use ofborg::easyamqp::{self, TypedWrappers}; @@ -15,7 +16,7 @@ fn main() { if memory_info.avail < 8 * 1024 * 1024 { // seems this stuff is in kilobytes? - println!( + error!( "Less than 8Gb of memory available (got {:.2}Gb). Aborting.", (memory_info.avail as f32) / 1024.0 / 1024.0 ); @@ -26,10 +27,10 @@ fn main() { ofborg::setup_log(); - println!("Hello, world!"); + info!("Hello, world!"); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let mut channel = session.open_channel(1).unwrap(); @@ -82,10 +83,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); } diff --git a/ofborg/src/bin/stats.rs b/ofborg/src/bin/stats.rs index 29d640b..99bf464 100644 --- a/ofborg/src/bin/stats.rs +++ b/ofborg/src/bin/stats.rs @@ -1,5 +1,6 @@ use amqp::Basic; use hyper::server::{Request, Response, Server}; +use log::{info, log}; use ofborg::easyamqp::TypedWrappers; use ofborg::{config, easyamqp, stats, tasks, worker}; @@ -10,10 +11,10 @@ fn main() { let cfg = config::load(env::args().nth(1).unwrap().as_ref()); ofborg::setup_log(); - println!("Hello, world!"); + info!("Hello, world!"); let mut session = easyamqp::session_from_config(&cfg.rabbitmq).unwrap(); - println!("Connected to rabbitmq"); + info!("Connected to rabbitmq"); let events = stats::RabbitMQ::new( &format!("{}-{}", cfg.runner.identity.clone(), cfg.nix.system.clone()), @@ -78,7 +79,7 @@ fn main() { thread::spawn(|| { let addr = "0.0.0.0:9898"; - println!("listening addr {:?}", addr); + info!("listening addr {:?}", addr); Server::http(addr) .unwrap() .handle(move |_: Request, res: Response| { @@ -89,10 +90,10 @@ fn main() { channel.start_consuming(); - println!("Finished consuming?"); + info!("Finished consuming?"); channel.close(200, "Bye").unwrap(); - println!("Closed the channel"); + info!("Closed the channel"); session.close(200, "Good Bye"); - println!("Closed the session... EOF"); + info!("Closed the session... EOF"); }