mirror of
https://github.com/mjl-/mox.git
synced 2025-06-28 08:18:16 +03:00
for trace logging, log size of the data (but not for redacted auth data, could be a password)
This commit is contained in:
parent
92a87acfcb
commit
ea55c85938
@ -301,14 +301,20 @@ func (l Log) Trace(level slog.Level, prefix string, data []byte) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var msg string
|
var msg string
|
||||||
|
size := -1
|
||||||
if hideData, hideAuth := traceLevel(filterLevel, level); hideData {
|
if hideData, hideAuth := traceLevel(filterLevel, level); hideData {
|
||||||
msg = prefix + "..."
|
msg = prefix + "..."
|
||||||
|
size = len(data)
|
||||||
} else if hideAuth {
|
} else if hideAuth {
|
||||||
msg = prefix + "***"
|
msg = prefix + "***"
|
||||||
} else {
|
} else {
|
||||||
msg = prefix + string(data)
|
msg = prefix + string(data)
|
||||||
|
size = len(data)
|
||||||
}
|
}
|
||||||
r := slog.NewRecord(time.Time{}, level, msg, 0)
|
r := slog.NewRecord(time.Time{}, level, msg, 0)
|
||||||
|
if size >= 0 {
|
||||||
|
r.AddAttrs(slog.Int("size", size))
|
||||||
|
}
|
||||||
ph.write(filterLevel, r)
|
ph.write(filterLevel, r)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user