diff --git a/lcli/src/main.rs b/lcli/src/main.rs index 2fd053885..e6a4eeeac 100644 --- a/lcli/src/main.rs +++ b/lcli/src/main.rs @@ -747,6 +747,7 @@ fn run( debug_level: "trace", logfile_debug_level: "trace", log_format: None, + log_color: false, max_log_size: 0, max_log_number: 0, compression: false, diff --git a/lighthouse/environment/src/lib.rs b/lighthouse/environment/src/lib.rs index 160f69654..679964c0d 100644 --- a/lighthouse/environment/src/lib.rs +++ b/lighthouse/environment/src/lib.rs @@ -47,6 +47,7 @@ pub struct LoggerConfig<'a> { pub debug_level: &'a str, pub logfile_debug_level: &'a str, pub log_format: Option<&'a str>, + pub log_color: bool, pub max_log_size: u64, pub max_log_number: usize, pub compression: bool, @@ -139,7 +140,13 @@ impl EnvironmentBuilder { _ => return Err("Logging format provided is not supported".to_string()), } } else { - let stdout_decorator = slog_term::TermDecorator::new().build(); + let stdout_decorator_builder = slog_term::TermDecorator::new(); + let stdout_decorator = if config.log_color { + stdout_decorator_builder.force_color() + } else { + stdout_decorator_builder + } + .build(); let stdout_decorator = logging::AlignedTermDecorator::new(stdout_decorator, logging::MAX_MESSAGE_WIDTH); let stdout_drain = slog_term::FullFormat::new(stdout_decorator).build().fuse(); diff --git a/lighthouse/src/main.rs b/lighthouse/src/main.rs index bd707f7a7..7897494cc 100644 --- a/lighthouse/src/main.rs +++ b/lighthouse/src/main.rs @@ -138,6 +138,13 @@ fn main() { .takes_value(true) .global(true), ) + .arg( + Arg::with_name("log-color") + .long("log-color") + .alias("log-colour") + .help("Force outputting colors when emitting logs to the terminal.") + .global(true), + ) .arg( Arg::with_name("debug-level") .long("debug-level") @@ -372,6 +379,8 @@ fn run( let log_format = matches.value_of("log-format"); + let log_color = matches.is_present("log-color"); + let logfile_debug_level = matches .value_of("logfile-debug-level") .ok_or("Expected --logfile-debug-level flag")?; @@ -424,6 +433,7 @@ fn run( debug_level, logfile_debug_level, log_format, + log_color, max_log_size: logfile_max_size * 1_024 * 1_024, max_log_number: logfile_max_number, compression: logfile_compress, diff --git a/testing/simulator/src/eth1_sim.rs b/testing/simulator/src/eth1_sim.rs index c54944c2e..613573cd0 100644 --- a/testing/simulator/src/eth1_sim.rs +++ b/testing/simulator/src/eth1_sim.rs @@ -65,6 +65,7 @@ pub fn run_eth1_sim(matches: &ArgMatches) -> Result<(), String> { debug_level: log_level, logfile_debug_level: "debug", log_format, + log_color: false, max_log_size: 0, max_log_number: 0, compression: false, diff --git a/testing/simulator/src/no_eth1_sim.rs b/testing/simulator/src/no_eth1_sim.rs index 5d2f0be72..28b871984 100644 --- a/testing/simulator/src/no_eth1_sim.rs +++ b/testing/simulator/src/no_eth1_sim.rs @@ -50,6 +50,7 @@ pub fn run_no_eth1_sim(matches: &ArgMatches) -> Result<(), String> { debug_level: log_level, logfile_debug_level: "debug", log_format, + log_color: false, max_log_size: 0, max_log_number: 0, compression: false, diff --git a/testing/simulator/src/sync_sim.rs b/testing/simulator/src/sync_sim.rs index 3bb460c9f..07d774b8d 100644 --- a/testing/simulator/src/sync_sim.rs +++ b/testing/simulator/src/sync_sim.rs @@ -51,6 +51,7 @@ fn syncing_sim( debug_level: log_level, logfile_debug_level: "debug", log_format, + log_color: false, max_log_size: 0, max_log_number: 0, compression: false,