Enable turning off the logs by default

This commit is contained in:
Graham Christensen 2018-01-20 12:20:54 -05:00
parent 2e5ab9dd1e
commit 9122586689
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
3 changed files with 26 additions and 4 deletions

View file

@ -49,13 +49,27 @@ fn main() {
let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root));
let nix = cfg.nix();
let full_logs: bool = match cfg.feedback.full_logs {
Some(true) => true,
None => {
warn!("Please define feedback.full_logs in your configuration to true or false!");
warn!("feedback.full_logs when true will cause the full build log to be sent back to the server, and be viewable by everyone.");
warn!("I strongly encourage everybody turn this on!");
false
}
_ => {
false
}
};
channel.basic_prefetch(1).unwrap();
channel.basic_consume(
notifyworker::new(tasks::build::BuildWorker::new(
cloner,
nix,
cfg.nix.system.clone(),
cfg.runner.identity.clone()
cfg.runner.identity.clone(),
full_logs,
)),
format!("build-inputs-{}", cfg.nix.system.clone()).as_ref(),
format!("{}-builder", cfg.whoami()).as_ref(),

View file

@ -23,7 +23,7 @@ pub struct Config {
#[derive(Serialize, Deserialize, Debug)]
pub struct FeedbackConfig {
pub full_logs: bool,
pub full_logs: Option<bool>,
}
#[derive(Serialize, Deserialize, Debug)]

View file

@ -24,15 +24,17 @@ pub struct BuildWorker {
nix: nix::Nix,
system: String,
identity: String,
full_logs: bool,
}
impl BuildWorker {
pub fn new(cloner: checkout::CachedCloner, nix: nix::Nix, system: String, identity: String) -> BuildWorker {
pub fn new(cloner: checkout::CachedCloner, nix: nix::Nix, system: String, identity: String, full_logs: bool) -> BuildWorker {
return BuildWorker{
cloner: cloner,
nix: nix,
system: system,
identity: identity,
full_logs: full_logs,
};
}
@ -228,8 +230,14 @@ impl notifyworker::SimpleNotifyWorker for BuildWorker {
let mut snippet_log = VecDeque::with_capacity(10);
if self.full_logs {
actions.log_line("Full logs are disabled on this builder.");
}
for line in spawned.lines().iter() {
actions.log_line(&line);
if self.full_logs {
actions.log_line(&line);
}
if snippet_log.len() >= 10 {