Skip to content

Commit

Permalink
do not log empty labels and comments (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanfkeepers authored Dec 12, 2024
1 parent 0111ba1 commit f05a5f8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions clog/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@ func (b builder) log(l logLevel, msg string) {
cv["error_labels"] = cluerr.Labels(b.err)
}

// finally, make sure we attach the labels and comments
cv["clog_labels"] = maps.Keys(b.labels)
cv["clog_comments"] = maps.Keys(b.comments)
// attach the labels and comments, if populated
if len(b.labels) > 0 {
cv["clog_labels"] = maps.Keys(b.labels)
}

if len(b.comments) > 0 {
cv["clog_comments"] = maps.Keys(b.comments)
}

if b.skipCallerJumps > 0 {
zsl = zsl.WithOptions(zap.AddCallerSkip(b.skipCallerJumps))
Expand Down

0 comments on commit f05a5f8

Please sign in to comment.