Skip to content

Commit

Permalink
add log contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
dryajov committed Jul 30, 2020
1 parent bd32ddf commit 0f88e99
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions libp2p/multistream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ proc handle*(m: MultistreamSelect, conn: Connection, active: bool = false) {.asy

if not handshaked and ms != Codec:
error "expected handshake message", instead=ms
raise newException(CatchableError,
raise newException(CatchableError,
"MultistreamSelect handling failed, invalid first message")

trace "handle: got request for ", ms
Expand All @@ -154,15 +154,15 @@ proc handle*(m: MultistreamSelect, conn: Connection, active: bool = false) {.asy
await conn.write(m.codec)
handshaked = true
else:
await conn.write(Na)
await conn.write(Na)
else:
for h in m.handlers:
if (not isNil(h.match) and h.match(ms)) or ms == h.proto:
trace "found handler for", protocol = ms
await conn.writeLp((h.proto & "\n"))
await h.protocol.handler(conn, ms)
return
debug "no handlers for ", protocol = ms
debug "no handlers for", protocol = ms
await conn.write(Na)
except CancelledError as exc:
await conn.close()
Expand Down
5 changes: 4 additions & 1 deletion libp2p/stream/connection.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
## those terms.

import hashes
import chronos, metrics
import chronos, metrics, chronicles
import lpstream,
../multiaddress,
../peerinfo

export lpstream

logScope:
topics = "connection"

const
ConnectionTrackerName* = "libp2p.connection"

Expand Down
3 changes: 3 additions & 0 deletions libp2p/stream/lpstream.nim
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import ../varint,

declareGauge(libp2p_open_streams, "open stream instances", labels = ["type"])

logScope:
topics = "lpstream"

type
LPStream* = ref object of RootObj
closeEvent*: AsyncEvent
Expand Down

0 comments on commit 0f88e99

Please sign in to comment.