diem_config/config/
logger_config.rs

1// Copyright (c) The Diem Core Contributors
2// SPDX-License-Identifier: Apache-2.0
3
4// Copyright 2021 Conflux Foundation. All rights reserved.
5// Conflux is free software and distributed under GNU General Public License.
6// See http://www.gnu.org/licenses/
7
8use diem_logger::{Level, CHANNEL_SIZE};
9use serde::{Deserialize, Serialize};
10use std::path::PathBuf;
11
12#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
13#[serde(default, deny_unknown_fields)]
14pub struct LoggerConfig {
15    // channel size for the asychronous channel for node logging.
16    pub chan_size: usize,
17    // Use async logging
18    pub is_async: bool,
19    // The default logging level for slog.
20    pub level: Level,
21    pub file: Option<PathBuf>,
22    // If this is None, we will not enable file rotation and
23    // `rotation_file_size_mb` will not be used.
24    pub rotation_count: Option<usize>,
25    // The maximal file size before rotation.
26    // The default value is set to 500MB.
27    pub rotation_file_size_mb: Option<usize>,
28}
29
30impl Default for LoggerConfig {
31    fn default() -> LoggerConfig {
32        LoggerConfig {
33            chan_size: CHANNEL_SIZE,
34            is_async: true,
35            level: Level::Info,
36            file: None,
37            rotation_count: None,
38            rotation_file_size_mb: None,
39        }
40    }
41}