aboutsummaryrefslogtreecommitdiff
path: root/crates/whirl_common/src/log.rs
blob: 38248cfeadc7fd4848052348b037a7f138a98186 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// Copyright (C) 2021-2021 The Whirlsplash Collective
// SPDX-License-Identifier: GPL-3.0-only

use whirl_config::Config;

/// Grab the log level configuration key (`whirlsplash.log.level`) from the
/// configuration file and evaluate the proper log level.
#[must_use]
pub fn calculate_log_level() -> String {
  let mut level;

  level = match Config::get().whirlsplash.log.level {
    2 => "debug".to_string(),
    3 => "trace".to_string(),
    _ => "info".to_string(),
  };
  if !Config::get().whirlsplash.log.everything {
    level = format!("whirl={}", level);
  }

  level
}