Skip to content

Commit 379edbf

Browse files
committed
log: append trace instead of prepending it
1 parent 6a45b1e commit 379edbf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

intra/log/logger.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ const similarUsrMsgThreshold = 3
223223
// less than 1024: github.com/golang/mobile/blob/2553ed8ce2/internal/mobileinit/mobileinit_android.go#L52
224224
const charsPerLine = 800
225225

226+
// prependTrace if true, prepends trace information to log msg; appends, otherwise.
227+
const prependTrace = false
228+
226229
// spamMsgThreshold is the min. no. of spammy msgs to report.
227230
var spammsgThreshold = [NONE + 1]uint32{
228231
VVERBOSE: 256 >> 1, // 128
@@ -707,11 +710,16 @@ func (l *simpleLogger) writelog(lvl LogLevel, at int, msg string, args ...any) {
707710
if tracecaller(x[0]) { // x[0] == file1 without fn info
708711
trace += x[0]
709712
}
713+
}
714+
if prependTrace {
710715
if len(trace) > 0 {
711716
trace += ": " // end-of-trace marker
712717
}
718+
msg = l.msgstr(lvl, trace+msg, args...)
719+
} else {
720+
msg += ": " // end-of-msg marker
721+
msg = l.msgstr(lvl, msg+trace, args...)
713722
}
714-
msg = l.msgstr(lvl, trace+msg, args...)
715723
if ll {
716724
// go's internal logger grabs mutex before every write
717725
l.out(msg)

0 commit comments

Comments
 (0)