Reduce the logging-related breaking changes (#3070)

* Reduce the logging-related breaking changes

* Don't disable the stdout log when the `--log-file` option is used
* Rename `--log-stdout` to `--log-format` and hide it
* Deprecate the `--log-file` option
This commit is contained in:
zah 2021-11-10 11:02:18 +02:00 committed by GitHub
parent 5c48982280
commit 2c0be052a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 10 deletions

View File

@ -90,13 +90,14 @@ type
name: "log-level" }: string name: "log-level" }: string
logStdout* {. logStdout* {.
hidden
desc: "Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)" desc: "Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)"
defaultValueDesc: "auto" defaultValueDesc: "auto"
defaultValue: StdoutLogKind.Auto defaultValue: StdoutLogKind.Auto
name: "log-stdout" }: StdoutLogKind name: "log-format" }: StdoutLogKind
logFile* {. logFile* {.
desc: "Specifies a path for the written Json log file" desc: "Specifies a path for the written Json log file (deprecated)"
name: "log-file" }: Option[OutFile] name: "log-file" }: Option[OutFile]
eth2Network* {. eth2Network* {.
@ -532,13 +533,14 @@ type
name: "log-level" }: string name: "log-level" }: string
logStdout* {. logStdout* {.
hidden
desc: "Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)" desc: "Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)"
defaultValueDesc: "auto" defaultValueDesc: "auto"
defaultValue: StdoutLogKind.Auto defaultValue: StdoutLogKind.Auto
name: "log-stdout" }: StdoutLogKind name: "log-format" }: StdoutLogKind
logFile* {. logFile* {.
desc: "Specifies a path for the written Json log file" desc: "Specifies a path for the written Json log file (deprecated)"
name: "log-file" }: Option[OutFile] name: "log-file" }: Option[OutFile]
dataDir* {. dataDir* {.

View File

@ -136,10 +136,7 @@ proc setupLogging*(
let tmp = let tmp =
if stdoutKind == StdoutLogKind.Auto: if stdoutKind == StdoutLogKind.Auto:
if logFile.isSome(): if isatty(stdout):
# No stdout logging by default, when file logging is enabled
StdoutLogKind.None
elif isatty(stdout):
# On a TTY, let's be fancy # On a TTY, let's be fancy
StdoutLogKind.Colors StdoutLogKind.Colors
else: else:
@ -167,6 +164,8 @@ proc setupLogging*(
of StdoutLogKind.None: of StdoutLogKind.None:
defaultChroniclesStream.outputs[0].writer = noOutput defaultChroniclesStream.outputs[0].writer = noOutput
if logFile.isSome():
warn "The --log-file option is deprecated. Consider redirecting the standard output to a file instead"
try: try:
updateLogLevel(logLevel) updateLogLevel(logLevel)
except ValueError as err: except ValueError as err:

View File

@ -50,3 +50,4 @@ To send logs to a file, you can redirect the stdout logs:
``` ```
We recommend keeping an eye on the growth of this file with a [log rotator](./log-rotate.md). Logs are written in the "JSON Lines" format - one `json` entry per line. We recommend keeping an eye on the growth of this file with a [log rotator](./log-rotate.md). Logs are written in the "JSON Lines" format - one `json` entry per line.

View File

@ -23,7 +23,7 @@ The following options are available:
--log-level Sets the log level for process and topics (e.g. "DEBUG; --log-level Sets the log level for process and topics (e.g. "DEBUG;
TRACE:discv5,libp2p; REQUIRED:none; DISABLED:none") [=INFO]. TRACE:discv5,libp2p; REQUIRED:none; DISABLED:none") [=INFO].
--log-stdout Specifies what kind of logs should be written to stdout --log-format Specifies what kind of logs should be written to stdout (beta)
(auto, colors, nocolors, json) [=auto]. (auto, colors, nocolors, json) [=auto].
--log-file Specifies a path for the written Json log file. --log-file Specifies a path for the written Json log file.
--network The Eth2 network to join [=mainnet]. --network The Eth2 network to join [=mainnet].

View File

@ -443,7 +443,7 @@ for NUM_NODE in $(seq 0 $(( NUM_NODES - 1 ))); do
--nat:extip:127.0.0.1 \ --nat:extip:127.0.0.1 \
--network="${DATA_DIR}" \ --network="${DATA_DIR}" \
--log-level="${LOG_LEVEL}" \ --log-level="${LOG_LEVEL}" \
--log-stdout=json \ --log-format=json \
--tcp-port=$(( BASE_PORT + NUM_NODE )) \ --tcp-port=$(( BASE_PORT + NUM_NODE )) \
--udp-port=$(( BASE_PORT + NUM_NODE )) \ --udp-port=$(( BASE_PORT + NUM_NODE )) \
--max-peers=$(( NUM_NODES - 1 )) \ --max-peers=$(( NUM_NODES - 1 )) \