simplify libp2p logging (#1605)

and a few other small logging fixes
This commit is contained in:
Jacek Sieka 2020-09-06 10:39:25 +02:00 committed by GitHub
parent c5f8ef8e40
commit d584591ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 12 deletions

View File

@ -90,4 +90,4 @@ type
ValidatorPool* = object
validators*: Table[ValidatorPubKey, AttachedValidator]
proc shortLog*(v: AttachedValidator): string = shortLog(v.pubKey)
func shortLog*(v: AttachedValidator): string = shortLog(v.pubKey)

View File

@ -197,13 +197,13 @@ type
template validator_keys*(e: EpochRef): untyped = e.validator_key_store[1][]
proc shortLog*(v: BlockSlot): string =
func shortLog*(v: BlockSlot): string =
if v.blck.slot == v.slot:
&"{v.blck.root.data.toOpenArray(0, 3).toHex()}:{v.blck.slot}"
else: # There was a gap - log it
&"{v.blck.root.data.toOpenArray(0, 3).toHex()}:{v.blck.slot}@{v.slot}"
proc shortLog*(v: BlockRef): string =
func shortLog*(v: BlockRef): string =
if v == nil:
"BlockRef(nil)"
else:

View File

@ -17,7 +17,7 @@ import
libp2p/protocols/secure/[secure, secio],
libp2p/protocols/pubsub/[pubsub, floodsub, gossipsub, rpc/message, rpc/messages],
libp2p/transports/tcptransport,
libp2p/stream/lpstream,
libp2p/stream/connection,
eth/[keys, async_utils], eth/p2p/p2p_protocol_dsl,
eth/net/nat, eth/p2p/discoveryv5/[enr, node],
# Beacon node modules
@ -26,7 +26,7 @@ import
peer_pool, spec/[datatypes, network], ./time
export
version, multiaddress, peer_pool, peerinfo, p2pProtocol,
version, multiaddress, peer_pool, peerinfo, p2pProtocol, connection,
libp2p_json_serialization, ssz_serialization, results
logScope:
@ -266,9 +266,8 @@ when libp2p_pki_schemes != "secp256k1":
template libp2pProtocol*(name: string, version: int) {.pragma.}
template `$`*(peer: Peer): string = id(peer.info)
chronicles.formatIt(Peer): $it
chronicles.formatIt(PeerID): $it
func shortLog*(peer: Peer): string = shortLog(peer.info.peerId)
chronicles.formatIt(Peer): shortLog(it)
template remote*(peer: Peer): untyped =
peer.info.peerId

View File

@ -2,7 +2,7 @@ import libp2p/daemon/daemonapi, json_serialization
export json_serialization
proc writeValue*(writer: var JsonWriter, value: PeerID) {.inline.} =
writer.writeValue value.pretty
writer.writeValue $value
proc readValue*(reader: var JsonReader, value: var PeerID) {.inline.} =
let res = PeerID.init reader.readValue(string)

View File

@ -121,7 +121,7 @@ proc readChunkPayload(conn: Connection, peer: Peer,
uint64(10 + size))
return ok SSZ.decode(data.get(), MsgType)
else:
debug "Snappy decompression/read failed", msg = $data.error, conn = $conn
debug "Snappy decompression/read failed", msg = $data.error, conn
return neterr InvalidSnappyBytes
proc readResponseChunk(conn: Connection, peer: Peer,

View File

@ -125,7 +125,7 @@ func asEth2Digest*(x: BlockHash): Eth2Digest =
template asBlockHash(x: Eth2Digest): BlockHash =
BlockHash(x.data)
func shortLog(b: Eth1Block): string =
func shortLog*(b: Eth1Block): string =
&"{b.number}:{shortLog b.voteData.block_hash}"
func getDepositsInRange(eth1Chain: Eth1Chain,

View File

@ -45,7 +45,7 @@ type
BlockRootsList* = List[Eth2Digest, Limit MAX_REQUEST_BLOCKS]
proc shortLog*(s: StatusMsg): auto =
func shortLog*(s: StatusMsg): auto =
(
forkDigest: s.forkDigest,
finalizedRoot: shortLog(s.finalizedRoot),