From 36f32f58d4bd030678ebc18cc3869257b9ac3f48 Mon Sep 17 00:00:00 2001 From: Tamo Date: Wed, 23 Jun 2021 11:07:19 +0200 Subject: [PATCH] add the log_level variable to the cli and reduce the log level of milli and grenad --- meilisearch-http/src/main.rs | 8 ++++++-- meilisearch-http/src/option.rs | 4 ++++ meilisearch-http/tests/common/server.rs | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/meilisearch-http/src/main.rs b/meilisearch-http/src/main.rs index 50201d912..3c51b7e72 100644 --- a/meilisearch-http/src/main.rs +++ b/meilisearch-http/src/main.rs @@ -19,8 +19,12 @@ const SENTRY_DSN: &str = "https://5ddfa22b95f241198be2271aaf028653@sentry.io/306 async fn main() -> Result<(), MainError> { let opt = Opt::from_args(); - let mut log_builder = - env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")); + let mut log_builder = env_logger::Builder::new(); + log_builder.parse_filters(&opt.log_level); + if opt.log_level == "info" { + // if we are in info we only allow the warn log_level for milli + log_builder.filter_module("milli", log::LevelFilter::Warn); + } match opt.env.as_ref() { "production" => { diff --git a/meilisearch-http/src/option.rs b/meilisearch-http/src/option.rs index 8cf2e0aba..0e75b63c8 100644 --- a/meilisearch-http/src/option.rs +++ b/meilisearch-http/src/option.rs @@ -188,6 +188,10 @@ pub struct Opt { #[structopt(long, conflicts_with = "import-snapshot")] pub import_dump: Option, + /// Set the log level + #[structopt(long, env = "MEILI_LOG_LEVEL", default_value = "info")] + pub log_level: String, + #[structopt(skip)] pub indexer_options: IndexerOpts, } diff --git a/meilisearch-http/tests/common/server.rs b/meilisearch-http/tests/common/server.rs index cd9dfb2d0..6cf1acb6a 100644 --- a/meilisearch-http/tests/common/server.rs +++ b/meilisearch-http/tests/common/server.rs @@ -91,5 +91,6 @@ pub fn default_settings(dir: impl AsRef) -> Opt { snapshot_interval_sec: 0, import_dump: None, indexer_options: IndexerOpts::default(), + log_level: "off".into(), } }