Stop using set_env to configure tracing-subscriber

This commit is contained in:
Jonas Platte 2022-01-22 13:27:54 +01:00
parent abb4b4cf0b
commit ce60fc6859
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67

View File

@ -184,9 +184,6 @@ fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<
#[rocket::main]
async fn main() {
// Force log level off, so we can use our own logger
std::env::set_var("CONDUIT_LOG_LEVEL", "off");
let raw_config =
Figment::from(default_config())
.merge(
@ -197,8 +194,6 @@ async fn main() {
)
.merge(Env::prefixed("CONDUIT_").global());
std::env::set_var("RUST_LOG", "warn");
let config = match raw_config.extract::<Config>() {
Ok(s) => s,
Err(e) => {
@ -244,8 +239,6 @@ async fn main() {
println!("exporting");
opentelemetry::global::shutdown_tracer_provider();
} else {
std::env::set_var("RUST_LOG", &config.log);
let registry = tracing_subscriber::Registry::default();
if config.tracing_flame {
let (flame_layer, _guard) =
@ -259,7 +252,7 @@ async fn main() {
start.await;
} else {
let fmt_layer = tracing_subscriber::fmt::Layer::new();
let filter_layer = EnvFilter::try_from_default_env()
let filter_layer = EnvFilter::try_new(&config.log)
.or_else(|_| EnvFilter::try_new("info"))
.unwrap();