update id/revision to make sense/no dupes, add stderr to the example

This commit is contained in:
askiiart 2025-01-17 22:55:46 -06:00
parent 870e63646e
commit 73ee302034
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
3 changed files with 49 additions and 4 deletions

View file

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

View file

@ -20,6 +20,7 @@ mod cli;
mod data;
mod errors;
mod tests;
mod logging;
fn main() {
let cli = Cli::parse();