diff --git a/nimbus/config.nim b/nimbus/config.nim index a8548574a..b141d73f8 100644 --- a/nimbus/config.nim +++ b/nimbus/config.nim @@ -1,4 +1,4 @@ -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -28,7 +28,9 @@ import common/chain_config, db/opts -export net, defs +from beacon_chain/nimbus_binary_common import setupLogging, StdoutLogKind + +export net, defs, StdoutLogKind const @@ -217,13 +219,16 @@ type logLevel* {. separator: "\pLOGGING AND DEBUGGING OPTIONS:" desc: "Sets the log level for process and topics (" & logLevelDesc & ")" - defaultValue: LogLevel.INFO - defaultValueDesc: $LogLevel.INFO - name: "log-level" }: LogLevel + defaultValue: "INFO" + defaultValueDesc: "Info topic level logging" + name: "log-level" }: string - logFile* {. - desc: "Specifies a path for the written Json log file" - name: "log-file" }: Option[OutFile] + logStdout* {. + hidden + desc: "Specifies what kind of logs should be written to stdout (auto, colors, nocolors, json)" + defaultValueDesc: "auto" + defaultValue: StdoutLogKind.Auto + name: "log-format" .}: StdoutLogKind logMetricsEnabled* {. desc: "Enable metrics logging" @@ -817,6 +822,8 @@ proc makeConfig*(cmdLine = commandLineParams()): NimbusConf except CatchableError as e: raise e + setupLogging(result.logLevel, result.logStdout, none(OutFile)) + var networkId = result.getNetworkId() if result.customNetwork.isSome: diff --git a/nimbus/nimbus_execution_client.nim b/nimbus/nimbus_execution_client.nim index 5a9ab9443..900506b41 100644 --- a/nimbus/nimbus_execution_client.nim +++ b/nimbus/nimbus_execution_client.nim @@ -1,5 +1,5 @@ # Nimbus -# Copyright (c) 2018-2024 Status Research & Development GmbH +# Copyright (c) 2018-2025 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE)) # * MIT license ([LICENSE-MIT](LICENSE-MIT)) @@ -174,14 +174,6 @@ proc preventLoadingDataDirForTheWrongNetwork(db: CoreDbRef; conf: NimbusConf) = quit(QuitFailure) proc run(nimbus: NimbusNode, conf: NimbusConf) = - ## logging - setLogLevel(conf.logLevel) - if conf.logFile.isSome: - let logFile = string conf.logFile.get() - defaultChroniclesStream.output.outFile = nil # to avoid closing stdout - discard defaultChroniclesStream.output.open(logFile, fmAppend) - - setupFileLimits() info "Launching execution client", version = FullVersionStr, @@ -290,19 +282,18 @@ proc run(nimbus: NimbusNode, conf: NimbusConf) = when isMainModule: var nimbus = NimbusNode(state: NimbusState.Starting, ctx: newEthContext()) + ## Processing command line arguments + let conf = makeConfig() + + setupFileLimits() + ## Ctrl+C handling proc controlCHandler() {.noconv.} = when defined(windows): # workaround for https://github.com/nim-lang/Nim/issues/4057 setupForeignThreadGc() nimbus.state = NimbusState.Stopping - echo "\nCtrl+C pressed. Waiting for a graceful shutdown." + notice "\nCtrl+C pressed. Waiting for a graceful shutdown." setControlCHook(controlCHandler) - ## Show logs on stdout until we get the user's logging choice - discard defaultChroniclesStream.output.open(stdout) - - ## Processing command line arguments - let conf = makeConfig() - nimbus.run(conf) diff --git a/nimbus/nimbus_execution_client.nim.cfg b/nimbus/nimbus_execution_client.nim.cfg new file mode 100644 index 000000000..4c0d44247 --- /dev/null +++ b/nimbus/nimbus_execution_client.nim.cfg @@ -0,0 +1,7 @@ +-d:"chronicles_sinks=textlines[dynamic],json[dynamic]" +-d:"chronicles_runtime_filtering=on" +-d:"chronicles_disable_thread_id" + +@if release: + -d:"chronicles_line_numbers:0" +@end