From b8b0a2b4bce8448b3aabc67fda96534124073c1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C8=98tefan=20Talpalaru?= Date: Tue, 14 Jul 2020 02:02:16 +0200 Subject: [PATCH] CI: build binaries with TRACE & JSON logs (#268) Also: remove unused imports. --- libp2p.nimble | 9 ++++++--- libp2p/multistream.nim | 1 - libp2p/muxers/mplex/lpchannel.nim | 2 -- libp2p/muxers/mplex/mplex.nim | 1 - libp2p/muxers/muxer.nim | 1 - libp2p/protocols/pubsub/floodsub.nim | 4 +--- libp2p/stream/chronosstream.nim | 3 +-- libp2p/switch.nim | 4 ---- libp2p/transports/tcptransport.nim | 5 +---- libp2p/transports/transport.nim | 5 ++--- tests/pubsub/testfloodsub.nim | 5 ++--- tests/testmultistream.nim | 2 +- tests/testswitch.nim | 6 ------ 13 files changed, 14 insertions(+), 34 deletions(-) diff --git a/libp2p.nimble b/libp2p.nimble index 267599028..106cd59d5 100644 --- a/libp2p.nimble +++ b/libp2p.nimble @@ -17,12 +17,15 @@ requires "nim >= 1.2.0", "stew >= 0.1.0" proc runTest(filename: string, verify: bool = true, sign: bool = true) = - var excstr = "nim c -r --opt:speed -d:debug --verbosity:0 --hints:off -d:chronicles_log_level=info" + var excstr = "nim c --opt:speed -d:debug --verbosity:0 --hints:off" excstr.add(" --warning[CaseTransition]:off --warning[ObservableStores]:off --warning[LockLevel]:off") excstr.add(" -d:libp2p_pubsub_sign=" & $sign) excstr.add(" -d:libp2p_pubsub_verify=" & $verify) - excstr.add(" tests/" & filename) - exec excstr + if verify and sign: + # build it with TRACE and JSON logs + exec excstr & " -d:chronicles_log_level=TRACE -d:chronicles_sinks:json" & " tests/" & filename + # build it again, to run it with less verbose logs + exec excstr & " -d:chronicles_log_level=INFO -r" & " tests/" & filename rmFile "tests/" & filename.toExe proc buildSample(filename: string) = diff --git a/libp2p/multistream.nim b/libp2p/multistream.nim index 4d4006838..57499da9d 100644 --- a/libp2p/multistream.nim +++ b/libp2p/multistream.nim @@ -11,7 +11,6 @@ import strutils import chronos, chronicles, stew/byteutils import stream/connection, vbuffer, - errors, protocols/protocol logScope: diff --git a/libp2p/muxers/mplex/lpchannel.nim b/libp2p/muxers/mplex/lpchannel.nim index 41be7cbad..ff63946d3 100644 --- a/libp2p/muxers/mplex/lpchannel.nim +++ b/libp2p/muxers/mplex/lpchannel.nim @@ -14,8 +14,6 @@ import types, nimcrypto/utils, ../../stream/connection, ../../stream/bufferstream, - ../../utility, - ../../errors, ../../peerinfo export connection diff --git a/libp2p/muxers/mplex/mplex.nim b/libp2p/muxers/mplex/mplex.nim index 69666419c..c11172da3 100644 --- a/libp2p/muxers/mplex/mplex.nim +++ b/libp2p/muxers/mplex/mplex.nim @@ -13,7 +13,6 @@ import ../muxer, ../../stream/connection, ../../stream/bufferstream, ../../utility, - ../../errors, ../../peerinfo, coder, types, diff --git a/libp2p/muxers/muxer.nim b/libp2p/muxers/muxer.nim index 2d6116037..001fbc761 100644 --- a/libp2p/muxers/muxer.nim +++ b/libp2p/muxers/muxer.nim @@ -10,7 +10,6 @@ import chronos, chronicles import ../protocols/protocol, ../stream/connection, - ../peerinfo, ../errors logScope: diff --git a/libp2p/protocols/pubsub/floodsub.nim b/libp2p/protocols/pubsub/floodsub.nim index cf43b70f4..a0fa44c64 100644 --- a/libp2p/protocols/pubsub/floodsub.nim +++ b/libp2p/protocols/pubsub/floodsub.nim @@ -15,9 +15,7 @@ import pubsub, rpc/[messages, message], ../../stream/connection, ../../peerid, - ../../peerinfo, - ../../utility, - ../../errors + ../../peerinfo logScope: topics = "floodsub" diff --git a/libp2p/stream/chronosstream.nim b/libp2p/stream/chronosstream.nim index 4c27ff2e5..1d200d5c3 100644 --- a/libp2p/stream/chronosstream.nim +++ b/libp2p/stream/chronosstream.nim @@ -7,9 +7,8 @@ ## This file may not be copied, modified, or distributed except according to ## those terms. -import oids import chronos, chronicles -import connection, ../utility +import connection logScope: topics = "chronosstream" diff --git a/libp2p/switch.nim b/libp2p/switch.nim index 015eb32a7..d9e047348 100644 --- a/libp2p/switch.nim +++ b/libp2p/switch.nim @@ -10,7 +10,6 @@ import tables, sequtils, options, - strformat, sets, algorithm, oids @@ -20,18 +19,15 @@ import chronos, metrics import stream/connection, - stream/chronosstream, transports/transport, multistream, multiaddress, protocols/protocol, protocols/secure/secure, - protocols/secure/plaintext, # for plain text peerinfo, protocols/identify, protocols/pubsub/pubsub, muxers/muxer, - errors, peerid logScope: diff --git a/libp2p/transports/tcptransport.nim b/libp2p/transports/tcptransport.nim index 6edb510ea..032b3e57b 100644 --- a/libp2p/transports/tcptransport.nim +++ b/libp2p/transports/tcptransport.nim @@ -16,9 +16,6 @@ import transport, ../stream/connection, ../stream/chronosstream -when chronicles.enabledLogLevel == LogLevel.TRACE: - import oids - logScope: topics = "tcptransport" @@ -74,7 +71,7 @@ proc connHandler*(t: TcpTransport, proc cleanup() {.async.} = try: await client.join() - trace "cleaning up client", addrs = client.remoteAddress, connoid = conn.oid + trace "cleaning up client", addrs = $client.remoteAddress, connoid = conn.oid if not(isNil(conn)): await conn.close() t.clients.keepItIf(it != client) diff --git a/libp2p/transports/transport.nim b/libp2p/transports/transport.nim index ff98c8ee8..a570d79a4 100644 --- a/libp2p/transports/transport.nim +++ b/libp2p/transports/transport.nim @@ -7,12 +7,11 @@ ## This file may not be copied, modified, or distributed except according to ## those terms. -import sequtils, tables +import sequtils import chronos, chronicles import ../stream/connection, ../multiaddress, - ../multicodec, - ../errors + ../multicodec type ConnHandler* = proc (conn: Connection): Future[void] {.gcsafe.} diff --git a/tests/pubsub/testfloodsub.nim b/tests/pubsub/testfloodsub.nim index 199921053..2d21b3118 100644 --- a/tests/pubsub/testfloodsub.nim +++ b/tests/pubsub/testfloodsub.nim @@ -9,7 +9,7 @@ {.used.} -import unittest, sequtils, options, tables, sets +import unittest, sequtils, options, tables import chronos, stew/byteutils import utils, ../../libp2p/[errors, @@ -18,8 +18,7 @@ import utils, crypto/crypto, protocols/pubsub/pubsub, protocols/pubsub/floodsub, - protocols/pubsub/rpc/messages, - protocols/pubsub/rpc/message] + protocols/pubsub/rpc/messages] import ../helpers diff --git a/tests/testmultistream.nim b/tests/testmultistream.nim index b36440be4..7f944b6cf 100644 --- a/tests/testmultistream.nim +++ b/tests/testmultistream.nim @@ -1,4 +1,4 @@ -import unittest, strutils, sequtils, strformat, stew/byteutils +import unittest, strutils, strformat, stew/byteutils import chronos import ../libp2p/errors, ../libp2p/multistream, diff --git a/tests/testswitch.nim b/tests/testswitch.nim index e06212504..a486b4034 100644 --- a/tests/testswitch.nim +++ b/tests/testswitch.nim @@ -9,19 +9,13 @@ import ../libp2p/[errors, multistream, standard_setup, stream/bufferstream, - protocols/identify, stream/connection, - transports/transport, - transports/tcptransport, multiaddress, peerinfo, crypto/crypto, protocols/protocol, muxers/muxer, muxers/mplex/mplex, - muxers/mplex/types, - protocols/secure/secio, - protocols/secure/secure, stream/lpstream] import ./helpers