lighthouse/lcli/src
Alexander Cyon 419c53bf24 Add flag 'log-color' preserving color of log redirected to file. (#3538)
Add flag 'log-color' which preserves colors of log when stdout is redirected to a file.

This is my first lighthouse PR, please let me know if I'm not following contribution guidelines, I welcome meta-feeback (feedback on git commit messages, git branch naming, and the contents of the description of this PR.)

## Issue Addressed

Solves https://github.com/sigp/lighthouse/issues/3527

## Proposed Changes

Adding a flag which enables log color preserving when stdout is redirected to a file.

### Usage
Below I demonstrate current behaviour (without using the new flag) and the new behaviur (when using new flag).

In the screenshot below, I have to panes, one on top running `lighthouse` which redirects to file `~/Desktop/test.log` and one pane in the bottom which runs `tail -f ~/Desktop/test.log`.

#### Current behaviour
```sh
lighthouse --network prater vc |& tee -a ~/Desktop/test.log
```

**Result is no colors**

<img width="1624" alt="current" src="https://user-images.githubusercontent.com/864410/188258226-bfcf8271-4c9e-474c-848e-ac92a60df25c.png">


#### New behaviour
```sh
lighthouse --network prater vc --log-color |& tee -a ~/Desktop/test.log
```

**Result is colors** 🔴🟢🔵🟡

<img width="1624" alt="new" src="https://user-images.githubusercontent.com/864410/188258223-7d9ecf09-92c8-4cba-8f24-bd4d88fc0353.png">

## Additional Info

I chose American spelling of "color" instead of Brittish "colour' since that was aligned with `slog`'s API - method`force_color()`, let me know if you prefer spelling "colour" instead. I also chose to let it be an arg not taking any argument, just like `logfile-compress` flag, rather than having to write `--log-color true`.
2022-09-06 05:58:27 +00:00
..
change_genesis_time.rs Altair consensus changes and refactors (#2279) 2021-07-09 06:15:32 +00:00
check_deposit_data.rs Update testnet tooling (#1001) 2020-04-19 02:20:43 +00:00
create_payload_header.rs Rename random to prev_randao (#3040) 2022-03-03 02:10:57 +00:00
deploy_deposit_contract.rs Fix local testnet scripts (#2229) 2021-03-30 05:17:58 +00:00
eth1_genesis.rs Unify execution layer endpoints (#3214) 2022-06-29 09:07:09 +00:00
generate_bootnode_enr.rs Additional networking metrics (#2549) 2021-12-22 06:17:14 +00:00
indexed_attestations.rs Add lcli indexed-attestations (#3221) 2022-05-31 06:09:08 +00:00
insecure_validators.rs Fix local testnet scripts (#2229) 2021-03-30 05:17:58 +00:00
interop_genesis.rs v1.1.1 spec updates (#2684) 2021-12-02 14:26:54 +11:00
main.rs Add flag 'log-color' preserving color of log redirected to file. (#3538) 2022-09-06 05:58:27 +00:00
new_testnet.rs Retrospective invalidation of exec. payloads for opt. sync (#2837) 2022-02-28 22:07:48 +00:00
parse_ssz.rs Realized unrealized experimentation (#3322) 2022-07-25 23:53:26 +00:00
replace_state_pubkeys.rs Update lcli pubkey replace command (#2677) 2021-12-02 14:26:53 +11:00
skip_slots.rs Add support for beaconAPI in lcli functions (#3252) 2022-08-09 06:05:13 +00:00
transition_blocks.rs Add support for beaconAPI in lcli functions (#3252) 2022-08-09 06:05:13 +00:00