From 1b8cec63f26b5896a827df5605475bdef2041bb2 Mon Sep 17 00:00:00 2001 From: Cole Helbling Date: Sun, 5 Apr 2020 23:26:05 -0700 Subject: [PATCH] treewide: replace `{e,}println!`s with `log` macros Currently, our logs are a bit inconsistent, with some being `{e,}println!`s and others utilizing macros from the `log` crate. One line might look like `INFO:ofborg::tasks::evaluate: Removing labels: []`, while the next might look like `Already: []`. --- ofborg/src/commitstatus.rs | 4 ++-- ofborg/src/tasks/build.rs | 18 +++++++++--------- ofborg/src/tasks/eval/nixpkgs.rs | 2 +- ofborg/src/tasks/eval/stdenvs.rs | 4 ++-- ofborg/src/tasks/evaluate.rs | 13 +++++++------ ofborg/src/tasks/githubcommentfilter.rs | 8 ++++---- ofborg/src/tasks/githubcommentposter.rs | 2 +- ofborg/src/tasks/log_message_collector.rs | 2 +- 8 files changed, 27 insertions(+), 26 deletions(-) diff --git a/ofborg/src/commitstatus.rs b/ofborg/src/commitstatus.rs index 7f0d70f..cf92180 100644 --- a/ofborg/src/commitstatus.rs +++ b/ofborg/src/commitstatus.rs @@ -46,8 +46,8 @@ impl<'a> CommitStatus<'a> { pub fn set(&self, state: hubcaps::statuses::State) -> Result<(), CommitStatusError> { let desc = if self.description.len() >= 140 { - eprintln!( - "Warning: description is over 140 char; truncating: {:?}", + warn!( + "description is over 140 char; truncating: {:?}", &self.description ); self.description.chars().take(140).collect() diff --git a/ofborg/src/tasks/build.rs b/ofborg/src/tasks/build.rs index bdf8158..27c184b 100644 --- a/ofborg/src/tasks/build.rs +++ b/ofborg/src/tasks/build.rs @@ -261,11 +261,11 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker { type J = buildjob::BuildJob; fn msg_to_job(&self, _: &Deliver, _: &BasicProperties, body: &[u8]) -> Result { - println!("lmao I got a job?"); + info!("lmao I got a job?"); match buildjob::from(body) { Ok(e) => Ok(e), Err(e) => { - println!("{:?}", String::from_utf8(body.to_vec())); + error!("{:?}", String::from_utf8(body.to_vec())); panic!("{:?}", e); } } @@ -316,7 +316,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker { return; } - println!( + info!( "Got path: {:?}, determining which ones we can build ", refpath ); @@ -332,7 +332,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker { .map(|(attr, _)| attr) .collect(); - println!( + info!( "Can build: '{}', Cannot build: '{}'", can_build.join(", "), cannot_build_attrs.join(", ") @@ -372,17 +372,17 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker { }, }; - println!("ok built ({:?}), building", status); - println!("Lines:\n-----8<-----"); + info!("ok built ({:?}), building", status); + info!("Lines:\n-----8<-----"); actions .log_snippet() .iter() - .inspect(|x| println!("{}", x)) + .inspect(|x| info!("{}", x)) .last(); - println!("----->8-----"); + info!("----->8-----"); actions.build_finished(status, can_build, cannot_build_attrs); - println!("Done!"); + info!("Done!"); } } diff --git a/ofborg/src/tasks/eval/nixpkgs.rs b/ofborg/src/tasks/eval/nixpkgs.rs index 01f4553..2cb64c2 100644 --- a/ofborg/src/tasks/eval/nixpkgs.rs +++ b/ofborg/src/tasks/eval/nixpkgs.rs @@ -575,7 +575,7 @@ fn request_reviews(maint: &maintainers::ImpactedMaintainers, pull: &hubcaps::pul team_reviewers: vec![], }) { - println!("Failure requesting a review from {}: {:?}", maintainer, e,); + warn!("Failure requesting a review from {}: {:?}", maintainer, e,); } } } diff --git a/ofborg/src/tasks/eval/stdenvs.rs b/ofborg/src/tasks/eval/stdenvs.rs index c5aa857..fcaeb34 100644 --- a/ofborg/src/tasks/eval/stdenvs.rs +++ b/ofborg/src/tasks/eval/stdenvs.rs @@ -101,12 +101,12 @@ impl Stdenvs { true, ); - println!("{:?}", result); + info!("{:?}", result); match result { Ok(mut out) => Some(file_to_str(&mut out)), Err(mut out) => { - println!("{:?}", file_to_str(&mut out)); + warn!("{:?}", file_to_str(&mut out)); None } } diff --git a/ofborg/src/tasks/evaluate.rs b/ofborg/src/tasks/evaluate.rs index 33c6ccb..edd4c52 100644 --- a/ofborg/src/tasks/evaluate.rs +++ b/ofborg/src/tasks/evaluate.rs @@ -163,8 +163,8 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { state: hubcaps::statuses::State, ) -> Result<(), hubcaps::Error> { let description = if description.len() >= 140 { - eprintln!( - "Warning: description is over 140 char; truncating: {:?}", + warn!( + "description is over 140 char; truncating: {:?}", &description ); description.chars().take(140).collect() @@ -210,7 +210,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { match eval_result { EvalWorkerError::CommitStatusWrite(e) => { - eprintln!( + error!( "Failed to write commit status, got error: {:?}, marking internal error", e ); @@ -218,7 +218,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]); } EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => { - eprintln!( + error!( "Failed to write commit status, got error: {:?}, marking internal error", e ); @@ -379,7 +379,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> { evaluation_strategy.after_merge(&mut overall_status)?; - println!("Got path: {:?}, building", refpath); + info!("Got path: {:?}, building", refpath); overall_status .set_with_description("Beginning Evaluations", hubcaps::statuses::State::Pending)?; @@ -532,7 +532,8 @@ pub fn update_labels(issue: &hubcaps::issues::IssueRef, add: &[String], remove: .iter() .map(|l| l.name.clone()) .collect(); - println!("Already: {:?}", existing); + info!("Already: {:?}", existing); + let to_add = add .iter() .filter(|l| !existing.contains(l)) // Remove labels already on the issue diff --git a/ofborg/src/tasks/githubcommentfilter.rs b/ofborg/src/tasks/githubcommentfilter.rs index 28b0859..f0e1412 100644 --- a/ofborg/src/tasks/githubcommentfilter.rs +++ b/ofborg/src/tasks/githubcommentfilter.rs @@ -30,7 +30,7 @@ impl worker::SimpleWorker for GitHubCommentWorker { match serde_json::from_slice(body) { Ok(e) => Ok(e), Err(e) => { - println!( + error!( "Failed to deserialize IsssueComment: {:?}", String::from_utf8(body.to_vec()) ); @@ -55,15 +55,15 @@ impl worker::SimpleWorker for GitHubCommentWorker { ); if build_destinations.is_empty() { - println!("No build destinations for: {:?}", job); + info!("No build destinations for: {:?}", job); // Don't process comments if they can't build anything return vec![worker::Action::Ack]; } - println!("Got job: {:?}", job); + info!("Got job: {:?}", job); let instructions = commentparser::parse(&job.comment.body); - println!("Instructions: {:?}", instructions); + info!("Instructions: {:?}", instructions); let pr = self .github diff --git a/ofborg/src/tasks/githubcommentposter.rs b/ofborg/src/tasks/githubcommentposter.rs index 6a27dc1..20eee6e 100644 --- a/ofborg/src/tasks/githubcommentposter.rs +++ b/ofborg/src/tasks/githubcommentposter.rs @@ -70,7 +70,7 @@ impl worker::SimpleWorker for GitHubCommentPoster { } for check in checks { - println!(":{:?}", check); + info!(":{:?}", check); let check_create_attempt = self .github_vend diff --git a/ofborg/src/tasks/log_message_collector.rs b/ofborg/src/tasks/log_message_collector.rs index 8405a66..fe67426 100644 --- a/ofborg/src/tasks/log_message_collector.rs +++ b/ofborg/src/tasks/log_message_collector.rs @@ -44,7 +44,7 @@ fn validate_path_segment(segment: &PathBuf) -> Result<(), String> { if segment.components().all(|component| match component { Component::Normal(_) => true, e => { - println!("Invalid path component: {:?}", e); + warn!("Invalid path component: {:?}", e); false } }) {