1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{
common::{
error::Result,
log::{init, proxy::LogProxy, tee_file::TeeFile, Log, LogRecord},
},
host::configuration::PluginLogConfiguration,
};
use ipc_channel::ipc::IpcSender;
pub fn setup_logging(
configuration: &PluginLogConfiguration,
log_channel: IpcSender<LogRecord>,
) -> Result<()> {
let mut loggers = Vec::with_capacity(1 + configuration.tee_files.len());
loggers.push(LogProxy::boxed(
configuration.name.as_str(),
configuration.verbosity,
log_channel,
) as Box<dyn Log>);
let tee_files: Result<Vec<_>> = configuration
.tee_files
.clone()
.into_iter()
.map(TeeFile::new)
.collect();
loggers.extend(tee_files?.into_iter().map(|l| Box::new(l) as Box<dyn Log>));
init(loggers)?;
Ok(())
}