pub mod acme;
pub mod cf;
pub mod config;
pub mod consts;
pub mod notify;
use tracing_subscriber::{
EnvFilter, Registry,
fmt::{
Layer,
format::{Compact, DefaultFields, Format},
*,
},
layer::Layered,
reload::*,
};
pub use crate::{acme::*, cf::*, config::*, consts::*, notify::*};
pub use anyhow::Result;
pub use anyhow::anyhow;
pub use tracing::{Level, debug, error, event, info, instrument, span, trace, warn};
type TracingEnvFilterHandle =
Handle<EnvFilter, Layered<Layer<Registry, DefaultFields, Format<Compact>>, Registry>>;
#[instrument]
pub fn initialize_logger() -> TracingEnvFilterHandle {
let env_log_filter = match EnvFilter::try_from_env("LOG") {
Ok(env_value_from_env) => env_value_from_env,
Err(_) => EnvFilter::from("info"),
};
let fmt = fmt()
.compact()
.with_target(true)
.with_line_number(false)
.with_file(false)
.with_thread_names(false)
.with_thread_ids(false)
.with_ansi(true)
.with_env_filter(env_log_filter)
.with_filter_reloading();
let handle = fmt.reload_handle();
fmt.init();
handle
}