Implement String() method on events

To make it safe for logging safelog.Scrub function is now public.

Closes: #40141
This commit is contained in:
meskio 2022-05-20 09:43:03 +02:00
parent 9757784c5a
commit 1d592b06e5
No known key found for this signature in database
GPG key ID: 52B8F5AC97A2DA86
3 changed files with 38 additions and 69 deletions

View file

@ -38,7 +38,7 @@ type LogScrubber struct {
func (ls *LogScrubber) Lock() { (*ls).lock.Lock() }
func (ls *LogScrubber) Unlock() { (*ls).lock.Unlock() }
func scrub(b []byte) []byte {
func Scrub(b []byte) []byte {
scrubbedBytes := b
for _, pattern := range scrubberPatterns {
// this is a workaround since go does not yet support look ahead or look
@ -62,7 +62,7 @@ func (ls *LogScrubber) Write(b []byte) (n int, err error) {
return
}
fullLines := ls.buffer[:i+1]
_, err = ls.Output.Write(scrub(fullLines))
_, err = ls.Output.Write(Scrub(fullLines))
if err != nil {
return
}