diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-12-03 08:17:11 +0100 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-12-03 08:17:11 +0100 |
commit | bfe392e19c5e422bb054a32ab35b7c15279cac9d (patch) | |
tree | 01f8524b114f482c500e6ca0386fdf7fa49eaafc /src/log | |
parent | 54a707001c3d333a0c201002ca2d1b3acf0f75bf (diff) |
Remove unused module: log::filesink
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'src/log')
-rw-r--r-- | src/log/filesink.rs | 61 | ||||
-rw-r--r-- | src/log/mod.rs | 3 |
2 files changed, 0 insertions, 64 deletions
diff --git a/src/log/filesink.rs b/src/log/filesink.rs deleted file mode 100644 index 39de00b..0000000 --- a/src/log/filesink.rs +++ /dev/null @@ -1,61 +0,0 @@ -use std::fs::File; -use std::fs::OpenOptions; -use std::io::Write; -use std::path::Path; -use std::path::PathBuf; - -use anyhow::Error; -use anyhow::Result; - -use crate::job::Job; -use crate::log::LogItem; -use crate::log::LogSink; - -pub struct FileSink { - file: File, -} - -impl FileSink { - fn new(path: &Path) -> Result<Self> { - OpenOptions::new() - .create(true) - .append(true) - .write(false) - .open(path) - .map(|file| FileSink { file }) - .map_err(Error::from) - } -} - -impl LogSink for FileSink { - fn log_item(&mut self, item: &LogItem) -> Result<()> { - let s = item.display()?; - writeln!(self.file, "{}", s)?; - Ok(()) - } -} - -pub struct FileLogSinkFactory { - root: PathBuf -} - -impl FileLogSinkFactory { - pub fn new(root: PathBuf) -> Self { - FileLogSinkFactory { root } - } - - pub fn new_file_sink(&self, job: &Job) -> Result<FileSink> { - let now = chrono::offset::Local::now() - .naive_local() - .format("%Y-%m-%dT%H:%M:%S"); - - trace!("Got current time: {}", now); - let filename = format!("{}-{}", now, job.package().name()); - - trace!("Building path from {} and {}", self.root.display(), filename); - let p = self.root.join(filename); - - FileSink::new(&p) - } -} - diff --git a/src/log/mod.rs b/src/log/mod.rs index bf24ad9..e3d8325 100644 --- a/src/log/mod.rs +++ b/src/log/mod.rs @@ -7,8 +7,5 @@ pub use item::*; mod sink; pub use sink::*; -mod filesink; -pub use filesink::*; - mod util; |