add the log_level variable to the cli and reduce the log level of milli and grenad

This commit is contained in:
Tamo 2021-06-23 11:07:19 +02:00
parent b4fd4212ad
commit 36f32f58d4
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69
3 changed files with 11 additions and 2 deletions

View File

@ -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" => {

View File

@ -188,6 +188,10 @@ pub struct Opt {
#[structopt(long, conflicts_with = "import-snapshot")]
pub import_dump: Option<PathBuf>,
/// Set the log level
#[structopt(long, env = "MEILI_LOG_LEVEL", default_value = "info")]
pub log_level: String,
#[structopt(skip)]
pub indexer_options: IndexerOpts,
}

View File

@ -91,5 +91,6 @@ pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
snapshot_interval_sec: 0,
import_dump: None,
indexer_options: IndexerOpts::default(),
log_level: "off".into(),
}
}