Explicitly restrict log level options to those that are documented

Fixes https://github.com/meilisearch/meilisearch/issues/3292
This commit is contained in:
Loïc Lecrenier 2023-01-03 11:55:34 +01:00
parent 947f08793a
commit d082ded7ad
4 changed files with 65 additions and 14 deletions

View file

@ -7,6 +7,7 @@ use actix_web::web::Data;
use actix_web::HttpServer;
use index_scheduler::IndexScheduler;
use meilisearch::analytics::Analytics;
use meilisearch::option::LogLevel;
use meilisearch::{analytics, create_app, setup_meilisearch, Opt};
use meilisearch_auth::{generate_master_key, AuthController, MASTER_KEY_MIN_SIZE};
@ -16,8 +17,8 @@ static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
/// does all the setup before meilisearch is launched
fn setup(opt: &Opt) -> anyhow::Result<()> {
let mut log_builder = env_logger::Builder::new();
log_builder.parse_filters(&opt.log_level);
if opt.log_level == "info" {
log_builder.parse_filters(&opt.log_level.to_string());
if matches!(opt.log_level, LogLevel::Info) {
// if we are in info we only allow the warn log_level for milli
log_builder.filter_module("milli", log::LevelFilter::Warn);
}