2022-02-28 19:49:42 +01:00
|
|
|
pub mod exec;
|
2021-07-26 21:14:12 +02:00
|
|
|
pub mod hash;
|
|
|
|
pub mod jobs;
|
|
|
|
|
2020-09-15 19:26:47 +02:00
|
|
|
use log::debug;
|
|
|
|
|
2020-09-14 21:18:53 +02:00
|
|
|
#[derive(Default)]
|
|
|
|
pub struct LoggerSink {
|
2020-09-15 19:26:47 +02:00
|
|
|
pub buffer: Vec<u8>,
|
2020-09-14 21:18:53 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
impl std::io::Write for LoggerSink {
|
|
|
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
|
|
|
self.buffer.extend(buf.iter());
|
|
|
|
|
|
|
|
if self.buffer.ends_with(b"\n") {
|
|
|
|
self.flush()?;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ok(buf.len())
|
|
|
|
}
|
|
|
|
|
|
|
|
fn flush(&mut self) -> std::io::Result<()> {
|
|
|
|
use std::str;
|
|
|
|
|
|
|
|
debug!(
|
|
|
|
"{}",
|
|
|
|
str::from_utf8(self.buffer.as_mut())
|
|
|
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidData, e))?
|
|
|
|
.trim()
|
|
|
|
);
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|