mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-07 16:55:46 +00:00
Add CLI flag to specify the format of logs written to the logfile (#3839)
## Proposed Changes Decouple the stdout and logfile formats by adding the `--logfile-format` CLI flag. This behaves identically to the existing `--log-format` flag, but instead will only affect the logs written to the logfile. The `--log-format` flag will no longer have any effect on the contents of the logfile. ## Additional Info This avoids being a breaking change by causing `logfile-format` to default to the value of `--log-format` if it is not provided. This means that users who were previously relying on being able to use a JSON formatted logfile will be able to continue to use `--log-format JSON`. Users who want to use JSON on stdout and default logs in the logfile, will need to pass the following flags: `--log-format JSON --logfile-format DEFAULT`
This commit is contained in:
@@ -50,6 +50,7 @@ pub struct LoggerConfig {
|
||||
pub debug_level: String,
|
||||
pub logfile_debug_level: String,
|
||||
pub log_format: Option<String>,
|
||||
pub logfile_format: Option<String>,
|
||||
pub log_color: bool,
|
||||
pub disable_log_timestamp: bool,
|
||||
pub max_log_size: u64,
|
||||
@@ -64,6 +65,7 @@ impl Default for LoggerConfig {
|
||||
debug_level: String::from("info"),
|
||||
logfile_debug_level: String::from("debug"),
|
||||
log_format: None,
|
||||
logfile_format: None,
|
||||
log_color: false,
|
||||
disable_log_timestamp: false,
|
||||
max_log_size: 200,
|
||||
@@ -252,7 +254,7 @@ impl<E: EthSpec> EnvironmentBuilder<E> {
|
||||
let file_logger = FileLoggerBuilder::new(&path)
|
||||
.level(logfile_level)
|
||||
.channel_size(LOG_CHANNEL_SIZE)
|
||||
.format(match config.log_format.as_deref() {
|
||||
.format(match config.logfile_format.as_deref() {
|
||||
Some("JSON") => Format::Json,
|
||||
_ => Format::default(),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user