blob: a9b90b0520a49a734662186642157b8e8165d76a (
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
|
extern crate navi;
use dns_common::prelude::{debug, error, tracing, tracing_subscriber};
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<()> {
tracing::subscriber::set_global_default(
tracing_subscriber::fmt()
.with_ansi(false)
// TODO: config_path/navi.log
.with_writer(std::fs::File::create("navi.log")?)
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.finish(),
)?;
debug!("tracing initialized");
Ok(())
}
|