From f65a0f7fdca3a98950b68cb424063f616e0b9757 Mon Sep 17 00:00:00 2001 From: "Brian J. Tarricone" Date: Tue, 31 Aug 2021 00:08:32 -0700 Subject: [PATCH] Don't set log level if not specified in config If we set a default here, it doesn't allow setting the level in the environment variable. --- src/main.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 5148763..9dd59ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,7 +5,6 @@ use config::{Config, InfluxDBConfig, MqttAuth, MqttConfig, UserAuth}; use futures::TryFutureExt; use influxdb::InfluxDbWriteable; use influxdb::{Client as InfluxClient, Timestamp, Type}; -use log::LevelFilter; use mapping::{Mapping, Payload, TagValue, TopicLevel}; use rumqttc::{ AsyncClient as MqttAsyncClient, Event, EventLoop as MqttEventLoop, Key, MqttOptions, Packet, @@ -253,9 +252,10 @@ async fn main() -> Result<(), String> { .filter("MQTT2DB_LOG") .write_style("MQTT2DB_LOG_STYLE"); let mut logger_builder = env_logger::Builder::from_env(logger_env); - logger_builder - .filter_level(config.log_level.unwrap_or(LevelFilter::Info)) - .init(); + if let Some(log_level) = config.log_level { + logger_builder.filter_level(log_level); + } + logger_builder.init(); let mappings: Vec> = config .mappings