Skip to content

Commit 05d5720

Browse files
committed
log: tiered spam msg threshold
1 parent 2f65a43 commit 05d5720

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

intra/log/logger.go

+12-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,17 @@ const similarTraceThreshold = 8
133133
const similarUsrMsgThreshold = 3
134134

135135
// spamMsgThreshold is the min. no. of spammy msgs to report.
136-
const spammsgThreshold = 24
136+
var spammsgThreshold = [NONE + 1]uint32{
137+
VVERBOSE: 256 >> 1, // 128
138+
VERBOSE: 256 >> 2, // 64
139+
DEBUG: 256 >> 3, // 32
140+
INFO: 256 >> 4, // 16
141+
WARN: 256 >> 5, // 8
142+
ERROR: 256 >> 6, // 4
143+
STACKTRACE: 256 >> 7, // 2
144+
USR: 256 >> 8, // 1
145+
NONE: 256 >> 9, // 0
146+
}
137147

138148
const defaultFlags = 0 // no flags
139149

@@ -423,7 +433,7 @@ func (l *simpleLogger) writelog(lvl LogLevel, at int, msg string, args ...any) {
423433
if l.spammy(lvl, pc) {
424434
l.skips[lvl].Add(1)
425435
return
426-
} else if n := l.skips[lvl].Swap(0); n > spammsgThreshold && (cc || ll) {
436+
} else if n := l.skips[lvl].Swap(0); n > spammsgThreshold[lvl] && (cc || ll) {
427437
spammsg := file + l.msgstr("spammy... dropped %d msgs", n)
428438
if ll {
429439
l.out(spammsg)

0 commit comments

Comments
 (0)