Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions book/src/help_bn.md
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,9 @@ Flags:
already-subscribed subnets, use with --subscribe-all-subnets to ensure
all attestations are received for import.
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_general.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ Flags:
-h, --help
Prints help information
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_vc.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,9 @@ Flags:
keys. If you misplace your database and then run with this flag you
risk being slashed.
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_vm.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ Flags:
-h, --help
Prints help information
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_vm_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ Flags:
-h, --help
Prints help information
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_vm_import.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ Flags:
something is amiss. Users should also be careful to avoid submitting
duplicate deposits for validators that already exist on the VC.
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
5 changes: 3 additions & 2 deletions book/src/help_vm_move.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@ Flags:
-h, --help
Prints help information
--log-color [<log-color>]
Enables/Disables colors for logs in terminal. Set it to false to
disable colors. [default: true] [possible values: true, false]
Enables/Disables colors for logs in terminal. If not specified, colors
are enabled only when stdout is a terminal. [possible values: true,
false]
--log-extra-info
If present, show module,file,line in logs
--logfile-color
Expand Down
16 changes: 6 additions & 10 deletions lighthouse/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ fn main() {
.long("log-color")
.alias("log-color")
.help("Enables/Disables colors for logs in terminal. \
Set it to false to disable colors.")
If not specified, colors are enabled only when stdout is a terminal.")
.num_args(0..=1)
.default_missing_value("true")
.default_value("true")
.value_parser(clap::value_parser!(bool))
.help_heading(FLAG_HEADER)
.global(true)
Expand Down Expand Up @@ -511,14 +510,11 @@ fn run<E: EthSpec>(

let log_format = matches.get_one::<String>("log-format");

let log_color = if std::io::stdin().is_terminal() {
matches
.get_one::<bool>("log-color")
.copied()
.unwrap_or(true)
} else {
// Disable color when in non-interactive mode.
false
let log_color = match matches.get_one::<bool>("log-color") {
// User specified whether logs should be colored.
Some(v) => *v,
// Otherwise, only use color if stdout is a terminal (i.e. not redirected to a file or piped)
None => std::io::stdout().is_terminal(),
};

let logfile_color = matches.get_flag("logfile-color");
Expand Down
Loading