[proxy] Restore INFO as the default tracing level

Also move tracing init to its own function.
This commit is contained in:
Dmitry Ivanov
2023-02-12 23:32:26 +03:00
parent f383b4d540
commit eaff14da5f

View File

@@ -41,13 +41,8 @@ async fn flatten_err(
#[tokio::main]
async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt()
.with_ansi(atty::is(atty::Stream::Stdout))
.with_env_filter(tracing_subscriber::EnvFilter::from_default_env())
.with_target(false)
.init();
// initialize sentry if SENTRY_DSN is provided
// First, initialize logging and troubleshooting subsystems.
init_tracing();
let _sentry_guard = init_sentry(Some(GIT_VERSION.into()), &[]);
info!("Version: {GIT_VERSION}");
@@ -112,6 +107,21 @@ async fn main() -> anyhow::Result<()> {
Ok(())
}
/// Tracing is used for logging and telemetry.
fn init_tracing() {
tracing_subscriber::fmt()
.with_env_filter({
// This filter will examine the `RUST_LOG` env variable.
use tracing_subscriber::filter::{EnvFilter, LevelFilter};
EnvFilter::builder()
.with_default_directive(LevelFilter::INFO.into())
.from_env_lossy()
})
.with_ansi(atty::is(atty::Stream::Stdout))
.with_target(false)
.init();
}
/// ProxyConfig is created at proxy startup, and lives forever.
fn build_config(args: &clap::ArgMatches) -> anyhow::Result<&'static ProxyConfig> {
let tls_config = match (