Skip to content

Commit

Permalink
Flush loggers before switching logger output to ensure only the audit…
Browse files Browse the repository at this point in the history
…able action function is responsible for the logs we see
  • Loading branch information
bbrks committed Aug 13, 2024
1 parent 1dd14ff commit bb64737
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions base/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ func AuditLogContents(t testing.TB, f func(t testing.TB)) []byte {
// Temporarily override logger output
b := &bytes.Buffer{}
mw := io.MultiWriter(b, os.Stderr)

FlushLogBuffers()
auditLogger.FlushBufferToLog()

auditLogger.logger.SetOutput(mw)
defer func() { auditLogger.logger.SetOutput(os.Stderr) }()

Expand Down

0 comments on commit bb64737

Please sign in to comment.