use super::super::LogResult; use super::{aggregators::Aggregator, formats::Format}; use std::{io::Write, sync::Mutex}; pub struct Pipeline { format: Box, aggregator: Box, writer: Mutex>, } impl Pipeline { pub fn new( writer: Box, format: Box, aggregator: Box, ) -> Pipeline { Pipeline { format, aggregator, writer: Mutex::new(writer), } } pub fn push_item(&self, item: LogResult) { let mut writer = self.writer.lock().unwrap(); self.aggregator.push_item(item, &*self.format, &mut *writer); } pub fn finish(self) { let mut writer = self.writer.lock().unwrap(); self.aggregator.finish(&*self.format, &mut *writer); } }