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:
parent
28d6cd2524
commit
7237a370ba
3
Makefile
3
Makefile
|
@ -129,6 +129,9 @@ testnet0 testnet1: | build deps
|
|||
schlesi: | build deps
|
||||
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
|
||||
rm -rf build/{$(TOOLS_CSV),all_tests,*_node,*ssz*,beacon_node_testnet*,state_sim,transition*}
|
||||
ifneq ($(USE_LIBBACKTRACE), 0)
|
||||
|
|
|
@ -7,11 +7,12 @@
|
|||
|
||||
import
|
||||
# Standard library
|
||||
os, tables, random, strutils, times,
|
||||
os, tables, random, strutils, times, sequtils,
|
||||
|
||||
# Nimble packages
|
||||
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,
|
||||
eth/db/kvstore, eth/db/kvstore_sqlite3,
|
||||
eth/p2p/enode, eth/[keys, async_utils], eth/p2p/discoveryv5/[protocol, enr],
|
||||
|
@ -1334,8 +1335,20 @@ programMain:
|
|||
|
||||
randomize()
|
||||
|
||||
if config.logLevel != LogLevel.NONE:
|
||||
setLogLevel(config.logLevel)
|
||||
try:
|
||||
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
|
||||
proc controlCHandler() {.noconv.} =
|
||||
|
|
|
@ -32,9 +32,9 @@ type
|
|||
|
||||
BeaconNodeConf* = object
|
||||
logLevel* {.
|
||||
defaultValue: LogLevel.DEBUG
|
||||
defaultValue: "DEBUG"
|
||||
desc: "Sets the log level."
|
||||
name: "log-level" }: LogLevel
|
||||
name: "log-level" }: string
|
||||
|
||||
eth1Network* {.
|
||||
defaultValue: goerli
|
||||
|
|
|
@ -684,6 +684,11 @@ proc dialPeer*(node: Eth2Node, peerInfo: PeerInfo) {.async.} =
|
|||
var peer = node.getPeer(peerInfo)
|
||||
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"
|
||||
await initializeConnection(peer)
|
||||
|
||||
|
|
|
@ -107,7 +107,7 @@ cli do (skipGoerliKey {.
|
|||
rmDir dataDir
|
||||
|
||||
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
|
||||
|
||||
|
@ -142,7 +142,7 @@ cli do (skipGoerliKey {.
|
|||
let logLevel = getEnv("LOG_LEVEL")
|
||||
var logLevelOpt = ""
|
||||
if logLevel.len > 0:
|
||||
logLevelOpt = "--log-level=" & logLevel
|
||||
logLevelOpt = &"""--log-level="{logLevel}" """
|
||||
|
||||
mode = Verbose
|
||||
execIgnoringExitCode replace(&"""{beaconNodeBinary}
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9c41783ba5b16e65f25b09d0e3dadae26dc56707
|
||||
Subproject commit 8be157d013be6cafe1ea4afcd5d4192c86fa0a3c
|
Loading…
Reference in New Issue