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: []`.
This commit is contained in:
Cole Helbling 2020-04-05 23:26:05 -07:00
parent 5c1a85ca31
commit 1b8cec63f2
No known key found for this signature in database
GPG key ID: B37E0F2371016A4C
8 changed files with 27 additions and 26 deletions

View file

@ -46,8 +46,8 @@ impl<'a> CommitStatus<'a> {
pub fn set(&self, state: hubcaps::statuses::State) -> Result<(), CommitStatusError> { pub fn set(&self, state: hubcaps::statuses::State) -> Result<(), CommitStatusError> {
let desc = if self.description.len() >= 140 { let desc = if self.description.len() >= 140 {
eprintln!( warn!(
"Warning: description is over 140 char; truncating: {:?}", "description is over 140 char; truncating: {:?}",
&self.description &self.description
); );
self.description.chars().take(140).collect() self.description.chars().take(140).collect()

View file

@ -261,11 +261,11 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
type J = buildjob::BuildJob; type J = buildjob::BuildJob;
fn msg_to_job(&self, _: &Deliver, _: &BasicProperties, body: &[u8]) -> Result<Self::J, String> { fn msg_to_job(&self, _: &Deliver, _: &BasicProperties, body: &[u8]) -> Result<Self::J, String> {
println!("lmao I got a job?"); info!("lmao I got a job?");
match buildjob::from(body) { match buildjob::from(body) {
Ok(e) => Ok(e), Ok(e) => Ok(e),
Err(e) => { Err(e) => {
println!("{:?}", String::from_utf8(body.to_vec())); error!("{:?}", String::from_utf8(body.to_vec()));
panic!("{:?}", e); panic!("{:?}", e);
} }
} }
@ -316,7 +316,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
return; return;
} }
println!( info!(
"Got path: {:?}, determining which ones we can build ", "Got path: {:?}, determining which ones we can build ",
refpath refpath
); );
@ -332,7 +332,7 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
.map(|(attr, _)| attr) .map(|(attr, _)| attr)
.collect(); .collect();
println!( info!(
"Can build: '{}', Cannot build: '{}'", "Can build: '{}', Cannot build: '{}'",
can_build.join(", "), can_build.join(", "),
cannot_build_attrs.join(", ") cannot_build_attrs.join(", ")
@ -372,17 +372,17 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
}, },
}; };
println!("ok built ({:?}), building", status); info!("ok built ({:?}), building", status);
println!("Lines:\n-----8<-----"); info!("Lines:\n-----8<-----");
actions actions
.log_snippet() .log_snippet()
.iter() .iter()
.inspect(|x| println!("{}", x)) .inspect(|x| info!("{}", x))
.last(); .last();
println!("----->8-----"); info!("----->8-----");
actions.build_finished(status, can_build, cannot_build_attrs); actions.build_finished(status, can_build, cannot_build_attrs);
println!("Done!"); info!("Done!");
} }
} }

View file

@ -575,7 +575,7 @@ fn request_reviews(maint: &maintainers::ImpactedMaintainers, pull: &hubcaps::pul
team_reviewers: vec![], team_reviewers: vec![],
}) })
{ {
println!("Failure requesting a review from {}: {:?}", maintainer, e,); warn!("Failure requesting a review from {}: {:?}", maintainer, e,);
} }
} }
} }

View file

@ -101,12 +101,12 @@ impl Stdenvs {
true, true,
); );
println!("{:?}", result); info!("{:?}", result);
match result { match result {
Ok(mut out) => Some(file_to_str(&mut out)), Ok(mut out) => Some(file_to_str(&mut out)),
Err(mut out) => { Err(mut out) => {
println!("{:?}", file_to_str(&mut out)); warn!("{:?}", file_to_str(&mut out));
None None
} }
} }

View file

@ -163,8 +163,8 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
state: hubcaps::statuses::State, state: hubcaps::statuses::State,
) -> Result<(), hubcaps::Error> { ) -> Result<(), hubcaps::Error> {
let description = if description.len() >= 140 { let description = if description.len() >= 140 {
eprintln!( warn!(
"Warning: description is over 140 char; truncating: {:?}", "description is over 140 char; truncating: {:?}",
&description &description
); );
description.chars().take(140).collect() description.chars().take(140).collect()
@ -210,7 +210,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
match eval_result { match eval_result {
EvalWorkerError::CommitStatusWrite(e) => { EvalWorkerError::CommitStatusWrite(e) => {
eprintln!( error!(
"Failed to write commit status, got error: {:?}, marking internal error", "Failed to write commit status, got error: {:?}, marking internal error",
e e
); );
@ -218,7 +218,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]); update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]);
} }
EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => { EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => {
eprintln!( error!(
"Failed to write commit status, got error: {:?}, marking internal error", "Failed to write commit status, got error: {:?}, marking internal error",
e e
); );
@ -379,7 +379,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
evaluation_strategy.after_merge(&mut overall_status)?; evaluation_strategy.after_merge(&mut overall_status)?;
println!("Got path: {:?}, building", refpath); info!("Got path: {:?}, building", refpath);
overall_status overall_status
.set_with_description("Beginning Evaluations", hubcaps::statuses::State::Pending)?; .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() .iter()
.map(|l| l.name.clone()) .map(|l| l.name.clone())
.collect(); .collect();
println!("Already: {:?}", existing); info!("Already: {:?}", existing);
let to_add = add let to_add = add
.iter() .iter()
.filter(|l| !existing.contains(l)) // Remove labels already on the issue .filter(|l| !existing.contains(l)) // Remove labels already on the issue

View file

@ -30,7 +30,7 @@ impl worker::SimpleWorker for GitHubCommentWorker {
match serde_json::from_slice(body) { match serde_json::from_slice(body) {
Ok(e) => Ok(e), Ok(e) => Ok(e),
Err(e) => { Err(e) => {
println!( error!(
"Failed to deserialize IsssueComment: {:?}", "Failed to deserialize IsssueComment: {:?}",
String::from_utf8(body.to_vec()) String::from_utf8(body.to_vec())
); );
@ -55,15 +55,15 @@ impl worker::SimpleWorker for GitHubCommentWorker {
); );
if build_destinations.is_empty() { 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 // Don't process comments if they can't build anything
return vec![worker::Action::Ack]; return vec![worker::Action::Ack];
} }
println!("Got job: {:?}", job); info!("Got job: {:?}", job);
let instructions = commentparser::parse(&job.comment.body); let instructions = commentparser::parse(&job.comment.body);
println!("Instructions: {:?}", instructions); info!("Instructions: {:?}", instructions);
let pr = self let pr = self
.github .github

View file

@ -70,7 +70,7 @@ impl worker::SimpleWorker for GitHubCommentPoster {
} }
for check in checks { for check in checks {
println!(":{:?}", check); info!(":{:?}", check);
let check_create_attempt = self let check_create_attempt = self
.github_vend .github_vend

View file

@ -44,7 +44,7 @@ fn validate_path_segment(segment: &PathBuf) -> Result<(), String> {
if segment.components().all(|component| match component { if segment.components().all(|component| match component {
Component::Normal(_) => true, Component::Normal(_) => true,
e => { e => {
println!("Invalid path component: {:?}", e); warn!("Invalid path component: {:?}", e);
false false
} }
}) { }) {