mirror of
https://github.com/sigp/lighthouse.git
synced 2026-05-09 03:17:55 +00:00
Merge remote-tracking branch 'origin/unstable' into capella
This commit is contained in:
@@ -24,6 +24,8 @@ gnosis = []
|
||||
slasher-mdbx = ["slasher/mdbx"]
|
||||
# Support slasher LMDB backend.
|
||||
slasher-lmdb = ["slasher/lmdb"]
|
||||
# Use jemalloc.
|
||||
jemalloc = ["malloc_utils/jemalloc"]
|
||||
|
||||
[dependencies]
|
||||
beacon_node = { "path" = "../beacon_node" }
|
||||
|
||||
@@ -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(),
|
||||
})
|
||||
|
||||
@@ -31,6 +31,14 @@ fn bls_library_name() -> &'static str {
|
||||
}
|
||||
}
|
||||
|
||||
fn allocator_name() -> &'static str {
|
||||
if cfg!(feature = "jemalloc") {
|
||||
"jemalloc"
|
||||
} else {
|
||||
"system"
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Enable backtraces unless a RUST_BACKTRACE value has already been explicitly provided.
|
||||
if std::env::var("RUST_BACKTRACE").is_err() {
|
||||
@@ -51,10 +59,12 @@ fn main() {
|
||||
"{}\n\
|
||||
BLS library: {}\n\
|
||||
SHA256 hardware acceleration: {}\n\
|
||||
Allocator: {}\n\
|
||||
Specs: mainnet (true), minimal ({}), gnosis ({})",
|
||||
VERSION.replace("Lighthouse/", ""),
|
||||
bls_library_name(),
|
||||
have_sha_extensions(),
|
||||
allocator_name(),
|
||||
cfg!(feature = "spec-minimal"),
|
||||
cfg!(feature = "gnosis"),
|
||||
).as_str()
|
||||
@@ -99,6 +109,15 @@ fn main() {
|
||||
.default_value("debug")
|
||||
.global(true),
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("logfile-format")
|
||||
.long("logfile-format")
|
||||
.value_name("FORMAT")
|
||||
.help("Specifies the log format used when emitting logs to the logfile.")
|
||||
.possible_values(&["DEFAULT", "JSON"])
|
||||
.takes_value(true)
|
||||
.global(true)
|
||||
)
|
||||
.arg(
|
||||
Arg::with_name("logfile-max-size")
|
||||
.long("logfile-max-size")
|
||||
@@ -402,6 +421,11 @@ fn run<E: EthSpec>(
|
||||
.value_of("logfile-debug-level")
|
||||
.ok_or("Expected --logfile-debug-level flag")?;
|
||||
|
||||
let logfile_format = matches
|
||||
.value_of("logfile-format")
|
||||
// Ensure that `logfile-format` defaults to the value of `log-format`.
|
||||
.or_else(|| matches.value_of("log-format"));
|
||||
|
||||
let logfile_max_size: u64 = matches
|
||||
.value_of("logfile-max-size")
|
||||
.ok_or("Expected --logfile-max-size flag")?
|
||||
@@ -452,6 +476,7 @@ fn run<E: EthSpec>(
|
||||
debug_level: String::from(debug_level),
|
||||
logfile_debug_level: String::from(logfile_debug_level),
|
||||
log_format: log_format.map(String::from),
|
||||
logfile_format: logfile_format.map(String::from),
|
||||
log_color,
|
||||
disable_log_timestamp,
|
||||
max_log_size: logfile_max_size * 1_024 * 1_024,
|
||||
|
||||
@@ -1662,7 +1662,24 @@ fn logfile_no_restricted_perms_flag() {
|
||||
assert!(config.logger_config.is_restricted == false);
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn logfile_format_default() {
|
||||
CommandLineTest::new()
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| assert_eq!(config.logger_config.logfile_format, None));
|
||||
}
|
||||
#[test]
|
||||
fn logfile_format_flag() {
|
||||
CommandLineTest::new()
|
||||
.flag("logfile-format", Some("JSON"))
|
||||
.run_with_zero_port()
|
||||
.with_config(|config| {
|
||||
assert_eq!(
|
||||
config.logger_config.logfile_format,
|
||||
Some("JSON".to_string())
|
||||
)
|
||||
});
|
||||
}
|
||||
#[test]
|
||||
fn sync_eth1_chain_default() {
|
||||
CommandLineTest::new()
|
||||
|
||||
Reference in New Issue
Block a user