blob: c20804bc5f27537b875b41f0b584c0f06c3ee08c (
plain)
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
|
use chrono::Local;
use fern::Dispatch;
use log::LevelFilter;
use std::{io, path::PathBuf};
const LOG_FILENAME: &str = "mullvad-loader.log";
pub fn init() -> Result<(), fern::InitError> {
Dispatch::new()
.format(|out, message, record| {
out.finish(format_args!(
"{} [{}] {}",
Local::now().format("%Y-%m-%d %H:%M:%S"),
record.level(),
message
))
})
.level(LevelFilter::Debug)
.chain(io::stdout())
.chain(fern::log_file(log_path())?)
.apply()?;
Ok(())
}
fn log_path() -> PathBuf {
std::env::temp_dir().join(LOG_FILENAME)
}
|