blob: 01f9ffb758a0ce48af679e0849b8a6db4a11c9e4 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
extern crate navi;
use dns_common::prelude::*;
use thiserror::Error;
#[derive(Error, Debug)]
#[error(
"\rHey, listen! navi encountered a problem.
Do you think this is a bug? File an issue at https://github.com/denisidoro/navi."
)]
pub struct FileAnIssue {
#[source]
source: anyhow::Error,
}
impl FileAnIssue {
pub fn new<SourceError>(source: SourceError) -> Self
where
SourceError: Into<anyhow::Error>,
{
FileAnIssue {
source: source.into(),
}
}
}
fn main() -> Result<(), anyhow::Error> {
init_logger()?;
navi::handle().map_err(|e| {
error!("{e:?}");
FileAnIssue::new(e).into()
})
}
fn init_logger() -> anyhow::Result<()> {
const FILE_NAME: &str = "navi.log";
let mut file = navi::default_config_pathbuf()?;
file.set_file_name(FILE_NAME);
tracing::subscriber::set_global_default(
tracing_subscriber::fmt()
.with_ansi(false)
.with_writer(std::fs::File::create(file)?)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.finish(),
)?;
debug!("tracing initialized");
Ok(())
}
|