update id/revision to make sense/no dupes, add stderr to the example
This commit is contained in:
parent
870e63646e
commit
73ee302034
3 changed files with 49 additions and 4 deletions
|
@ -27,15 +27,15 @@ max-threads = 10
|
|||
[packages.some-librewolf-dependency]
|
||||
|
||||
[packages.some-librewolf-dependency.compilation]
|
||||
id = "1"
|
||||
revision = "2"
|
||||
id = "2"
|
||||
revision = "4"
|
||||
threads = 2
|
||||
image = "docker.io/library/debian"
|
||||
commands = ["echo hi", "echo helloooooooooo"]
|
||||
commands = ["echo hi", "echo helloooooooooo >&2"]
|
||||
volumes = ["other-workspace"]
|
||||
|
||||
[packages.some-librewolf-dependency.packaging.fedora]
|
||||
id = "1"
|
||||
id = "3"
|
||||
revision = "2"
|
||||
threads = 2
|
||||
image = "docker.io/library/fedora"
|
||||
|
|
44
src/logging.rs
Normal file
44
src/logging.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
use crate::errors::Error;
|
||||
use std::io::Write;
|
||||
use std::{
|
||||
fs::{File, OpenOptions},
|
||||
os::unix::fs::FileExt,
|
||||
};
|
||||
|
||||
/// The logger for gregory itself - NOT for jobs
|
||||
pub(crate) struct Logger {
|
||||
log_file: File,
|
||||
}
|
||||
|
||||
impl Logger {
|
||||
pub(crate) fn new(path: String) -> Result<Logger, Error> {
|
||||
match OpenOptions::new().append(true).open(path) {
|
||||
Ok(f) => return Ok(Logger { log_file: f }),
|
||||
Err(e) => {
|
||||
return Err(Error::IOError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Log a warning
|
||||
///
|
||||
/// Fun gregory lore: I originally typo'd this as "Strign" and the linter didn't catch it for some reason
|
||||
pub(crate) fn warning(&mut self, text: String) -> Result<(), Error> {
|
||||
match writeln!(&mut self.log_file, "[WARNING] {}", text) {
|
||||
Ok(_) => return Ok(()),
|
||||
Err(e) => {
|
||||
return Err(Error::IOError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Log an error
|
||||
pub(crate) fn error(&mut self, text: String) -> Result<(), Error> {
|
||||
match writeln!(&mut self.log_file, "[ERROR] {}", text) {
|
||||
Ok(_) => return Ok(()),
|
||||
Err(e) => {
|
||||
return Err(Error::IOError(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -20,6 +20,7 @@ mod cli;
|
|||
mod data;
|
||||
mod errors;
|
||||
mod tests;
|
||||
mod logging;
|
||||
|
||||
fn main() {
|
||||
let cli = Cli::parse();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue