Protect logger targets (#13529)

Logger targets were not race protected against concurrent updates from for example `HTTPConsoleLoggerSys`.

Restrict direct access to targets and make slices immutable so a returned slice can be processed safely without locks.
This commit is contained in:
Klaus Post
2021-10-28 07:35:28 -07:00
committed by GitHub
parent bd88b86919
commit d9c1d79e30
6 changed files with 75 additions and 13 deletions

View File

@@ -379,7 +379,7 @@ func logIf(ctx context.Context, err error, errKind ...interface{}) {
}
// Iterate over all logger targets to send the log entry
for _, t := range Targets {
for _, t := range Targets() {
t.Send(entry, entry.LogKind)
}
}