-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(logs): remove duplicate msg key #1180
Conversation
@@ -106,7 +106,7 @@ method rpcHandler*(f: FloodSub, peer: PubSubPeer, data: seq[byte]) {.async.} = | |||
debug "failed to decode msg from peer", peer, err = error | |||
raise newException(CatchableError, "Peer msg couldn't be decoded") | |||
|
|||
trace "decoded msg from peer", peer, msg = rpcMsg.shortLog | |||
trace "decoded msg from peer", peer, payload = rpcMsg.shortLog |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msgShortLog?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kind of the same reasoning, payload
is a widely accepted word for this situations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not logging the whole content
Lines 24 to 34 in 96bfefc
func shortLog*(item: openArray[byte]): string = | |
if item.len <= ShortDumpMax: | |
result = item.toHex() | |
else: | |
const | |
split = ShortDumpMax div 2 | |
dumpLen = (ShortDumpMax * 2) + 3 | |
result = newStringOfCap(dumpLen) | |
result &= item.toOpenArray(0, split - 1).toHex() | |
result &= "..." | |
result &= item.toOpenArray(item.len - split, item.high).toHex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would that be an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shortLog
creates a shortened representation of the data, it's not the payload. What about summary
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shortLog
is actually a bit of an abused name, as it vastly depends on the object being shortlogged: Some are actual short representations, some others are obfuscated representations, and others are the full object representations.
What I mean is: There's not a unique key that perfectly handles all cases; unless we go for a very generic context
or the likes, which doesn't really provide meaning. Ideally it should be handled on a case by case basis, but I think that's a different task altogether.
Personally, I'd stick to payload
as it's already there and we can get it merged already, and create a chore to keep track of this naming issue and spend on time whenever we feel appropriate. That is, unless you strongly oppose it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, could you please create an issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done: #1181
@@ -219,7 +219,7 @@ method publish*(f: FloodSub, topic: string, data: seq[byte]): Future[int] {.asyn | |||
trace "Error generating message id, skipping publish", error = error | |||
return 0 | |||
|
|||
trace "Created new message", msg = shortLog(msg), peers = peers.len, topic, msgId | |||
trace "Created new message", payload = shortLog(msg), peers = peers.len, topic, msgId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
msgShortLog?
Chronicles uses
msg
for the string that describes the log, so this PR removes the duplicatemsg
usage.closes: #1176