From a7f14bc9b783f1b9e2d02cc85a338b1411058095 Mon Sep 17 00:00:00 2001 From: Dmitriy Ryajov Date: Mon, 20 Nov 2023 11:34:40 -0600 Subject: [PATCH] Fix logging format (#87) * add shortLog for Address * compile with trace logging to catch errors --- build.nims | 7 +++++++ codexdht/private/eth/p2p/discoveryv5/encoding.nim | 2 +- codexdht/private/eth/p2p/discoveryv5/node.nim | 5 +++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/build.nims b/build.nims index 5dc4b68..5801ada 100644 --- a/build.nims +++ b/build.nims @@ -2,15 +2,22 @@ import std / [os, strutils, sequtils] task testAll, "Run DHT tests": exec "nim c -r tests/testAll.nim" + rmFile "./tests/testAll" task test, "Run DHT tests": + # compile with trace logging to make sure it doesn't crash + exec "nim c -d:testsAll -d:chronicles_enabled=on -d:chronicles_log_level=TRACE tests/testAll.nim" + rmFile "./tests/testAll" exec "nim c -r -d:testsAll --verbosity:0 tests/testAllParallel.nim" + rmFile "./tests/testAllParallel" task testPart1, "Run DHT tests A": exec "nim c -r -d:testsPart1 tests/testAllParallel.nim" + rmFile "./tests/testAllParallel" task testPart2, "Run DHT tests B": exec "nim c -r -d:testsPart2 tests/testAllParallel.nim" + rmFile "./tests/testAllParallel" task coverage, "generates code coverage report": var (output, exitCode) = gorgeEx("which lcov") diff --git a/codexdht/private/eth/p2p/discoveryv5/encoding.nim b/codexdht/private/eth/p2p/discoveryv5/encoding.nim index bf7294f..2520b28 100644 --- a/codexdht/private/eth/p2p/discoveryv5/encoding.nim +++ b/codexdht/private/eth/p2p/discoveryv5/encoding.nim @@ -441,7 +441,7 @@ proc decodeMessagePacket(c: var Codec, fromAddr: Address, nonce: AESGCMNonce, if pt.isNone(): # Don't consider this an error, the session got probably removed at the # peer's side and a random message is send. - # This might also be a cross-connect. Not deleteing key, as it might be + # This might also be a cross-connect. Not deleting key, as it might be # needed later, depending on message order. trace "Decrypting failed (invalid keys)", address = fromAddr #c.sessions.del(srcId, fromAddr) diff --git a/codexdht/private/eth/p2p/discoveryv5/node.nim b/codexdht/private/eth/p2p/discoveryv5/node.nim index 3d1cdf2..0f08aec 100644 --- a/codexdht/private/eth/p2p/discoveryv5/node.nim +++ b/codexdht/private/eth/p2p/discoveryv5/node.nim @@ -177,3 +177,8 @@ func shortLog*(nodes: seq[Node]): string = result.add("]") chronicles.formatIt(seq[Node]): shortLog(it) + +func shortLog*(address: Address): string = + $address + +chronicles.formatIt(Address): shortLog(it)