Merge pull request #452 from cole-h/logging

Logging cleanup
This commit is contained in:
Graham Christensen 2020-04-06 06:00:48 -04:00 committed by GitHub
commit 2541d183bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 83 additions and 74 deletions

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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![]);

View file

@ -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");
}

View file

@ -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");
}

View file

@ -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()

View file

@ -197,11 +197,11 @@ impl GithubAppVendingMachine {
match lookup_gh.app().find_repo_installation(owner, repo) {
Ok(install_id) => {
debug!("Received install ID {:#?}", install_id);
debug!("Received install ID {:?}", install_id);
Some(install_id.id)
}
Err(e) => {
warn!("Error during install ID lookup: {:#?}", e);
warn!("Error during install ID lookup: {:?}", e);
None
}
}

View file

@ -155,7 +155,7 @@ impl Error {
}
}
Error::UncleanEvaluation(warnings) => {
format!("nix-env did not evaluate cleanly:\n {:#?}", warnings)
format!("nix-env did not evaluate cleanly:\n {:?}", warnings)
}
Error::StatsParse(mut fd, seek, parse_err) => {
let mut buffer = Vec::new();

View file

@ -261,11 +261,11 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
type J = buildjob::BuildJob;
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) {
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!");
}
}

View file

@ -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,);
}
}
}

View file

@ -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
}
}

View file

@ -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,16 +210,16 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
match eval_result {
EvalWorkerError::CommitStatusWrite(e) => {
eprintln!(
"Failed to write commit status, got error: {:#?}, marking internal error",
error!(
"Failed to write commit status, got error: {:?}, marking internal error",
e
);
let issue_ref = self.repo.issue(self.job.pr.number);
update_labels(&issue_ref, &[String::from("ofborg-internal-error")], &[]);
}
EvalWorkerError::EvalError(eval::Error::CommitStatusWrite(e)) => {
eprintln!(
"Failed to write commit status, got error: {:#?}, marking internal error",
error!(
"Failed to write commit status, got error: {:?}, marking internal error",
e
);
let issue_ref = self.repo.issue(self.job.pr.number);
@ -228,7 +228,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
EvalWorkerError::EvalError(eval::Error::Fail(msg)) => {
self.update_status(msg.clone(), None, hubcaps::statuses::State::Failure)
.unwrap_or_else(|e| {
panic!("Failed to set plain status: {}; e: {:#?}", msg, e);
panic!("Failed to set plain status: {}; e: {:?}", msg, e);
});
}
EvalWorkerError::EvalError(eval::Error::FailWithGist(msg, filename, content)) => {
@ -239,7 +239,7 @@ impl<'a, E: stats::SysEvents + 'static> OneEval<'a, E> {
)
.unwrap_or_else(|e| {
panic!(
"Failed to set status with a gist: {}, {}, {}; e: {:#?}",
"Failed to set status with a gist: {}, {}, {}; e: {:?}",
msg, filename, content, 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)?;
@ -469,7 +469,7 @@ fn schedule_builds(
) -> Vec<worker::Action> {
let mut response = vec![];
info!(
"Scheduling build jobs {:#?} on arches {:#?}",
"Scheduling build jobs {:?} on arches {:?}",
builds, auto_schedule_build_archs
);
for buildjob in builds {
@ -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

View file

@ -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

View file

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

View file

@ -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
}
}) {