Please see the newly added 'schlesi-dev' Makefile target.
It demonstrates how the log level can be specified for individual topics.

Additionally, when connecting to testnets like 'schlesi' there will be
two additional log files produced in the working directory:

* json-log.txt
* text-log.txt (in the textblocks format)
This commit is contained in:
Zahary Karadjov 2020-04-28 01:39:04 +03:00 committed by zah
parent 28d6cd2524
commit 7237a370ba
6 changed files with 30 additions and 9 deletions

View File

@ -129,6 +129,9 @@ testnet0 testnet1: | build deps
schlesi: | build deps schlesi: | build deps
LOG_LEVEL="DEBUG" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi LOG_LEVEL="DEBUG" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi
schlesi-dev: | build deps
LOG_LEVEL="DEBUG;TRACE:discv5,networking;REQUIRED:none" $(ENV_SCRIPT) nim $(NIM_PARAMS) scripts/connect_to_testnet.nims $(SCRIPT_PARAMS) shared/schlesi
clean: | clean-common clean: | clean-common
rm -rf build/{$(TOOLS_CSV),all_tests,*_node,*ssz*,beacon_node_testnet*,state_sim,transition*} rm -rf build/{$(TOOLS_CSV),all_tests,*_node,*ssz*,beacon_node_testnet*,state_sim,transition*}
ifneq ($(USE_LIBBACKTRACE), 0) ifneq ($(USE_LIBBACKTRACE), 0)

View File

@ -7,11 +7,12 @@
import import
# Standard library # Standard library
os, tables, random, strutils, times, os, tables, random, strutils, times, sequtils,
# Nimble packages # Nimble packages
stew/[objects, bitseqs, byteutils], stew/shims/macros, stew/[objects, bitseqs, byteutils], stew/shims/macros,
chronos, chronicles, confutils, metrics, json_rpc/[rpcserver, jsonmarshal], chronos, confutils, metrics, json_rpc/[rpcserver, jsonmarshal],
chronicles, chronicles/helpers as chroniclesHelpers,
json_serialization/std/[options, sets, net], serialization/errors, json_serialization/std/[options, sets, net], serialization/errors,
eth/db/kvstore, eth/db/kvstore_sqlite3, eth/db/kvstore, eth/db/kvstore_sqlite3,
eth/p2p/enode, eth/[keys, async_utils], eth/p2p/discoveryv5/[protocol, enr], eth/p2p/enode, eth/[keys, async_utils], eth/p2p/discoveryv5/[protocol, enr],
@ -1334,8 +1335,20 @@ programMain:
randomize() randomize()
if config.logLevel != LogLevel.NONE: try:
setLogLevel(config.logLevel) let directives = config.logLevel.split(";")
try:
setLogLevel(parseEnum[LogLevel](directives[0]))
except CatchableError:
raise (ref ValueError)(msg: "Please specify one of TRACE, DEBUG, INFO, NOTICE, WARN, ERROR or FATAL")
if directives.len > 1:
for topicName, settings in parseTopicDirectives(directives[1..^1]):
if not setTopicState(topicName, settings.state, settings.logLevel):
warn "Unrecognized logging topic", topic = topicName
except CatchableError as err:
stderr.write "Invalid value for --log-level. " & err.msg
quit 1
## Ctrl+C handling ## Ctrl+C handling
proc controlCHandler() {.noconv.} = proc controlCHandler() {.noconv.} =

View File

@ -32,9 +32,9 @@ type
BeaconNodeConf* = object BeaconNodeConf* = object
logLevel* {. logLevel* {.
defaultValue: LogLevel.DEBUG defaultValue: "DEBUG"
desc: "Sets the log level." desc: "Sets the log level."
name: "log-level" }: LogLevel name: "log-level" }: string
eth1Network* {. eth1Network* {.
defaultValue: goerli defaultValue: goerli

View File

@ -684,6 +684,11 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
var peer = node.getPeer(peerInfo) var peer = node.getPeer(peerInfo)
peer.wasDialed = true peer.wasDialed = true
#let msDial = newMultistream()
#let conn = node.switch.connections.getOrDefault(peerInfo.id)
#let ls = await msDial.list(conn)
#debug "Supported protocols", ls
debug "Initializing connection" debug "Initializing connection"
await initializeConnection(peer) await initializeConnection(peer)

View File

@ -107,7 +107,7 @@ cli do (skipGoerliKey {.
rmDir dataDir rmDir dataDir
cd rootDir cd rootDir
exec &"""nim c {nimFlags} -d:"const_preset={preset}" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim""" exec &"""nim c {nimFlags} -d:"const_preset={preset}" -d:"chronicles_sinks=textlines,json[file(json-log.txt)],textblocks[file(text-log.txt)]" -o:"{beaconNodeBinary}" beacon_chain/beacon_node.nim"""
mkDir dumpDir mkDir dumpDir
@ -142,7 +142,7 @@ cli do (skipGoerliKey {.
let logLevel = getEnv("LOG_LEVEL") let logLevel = getEnv("LOG_LEVEL")
var logLevelOpt = "" var logLevelOpt = ""
if logLevel.len > 0: if logLevel.len > 0:
logLevelOpt = "--log-level=" & logLevel logLevelOpt = &"""--log-level="{logLevel}" """
mode = Verbose mode = Verbose
execIgnoringExitCode replace(&"""{beaconNodeBinary} execIgnoringExitCode replace(&"""{beaconNodeBinary}

@ -1 +1 @@
Subproject commit 9c41783ba5b16e65f25b09d0e3dadae26dc56707 Subproject commit 8be157d013be6cafe1ea4afcd5d4192c86fa0a3c