mirror of
https://github.com/kopia/kopia.git
synced 2026-05-11 00:04:46 -04:00
Previously some logs from a running server were only kept in memory (including storage activity logs) which was confusing to many folks. This changes the behavior so that logs are sent to their regular (console/file) file locations in addition to the UI tasks. Old behavior can be restored by adding `--no-persistent-logs` to server.
30 lines
516 B
Go
30 lines
516 B
Go
package logging
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
// Broadcast is a logger that broadcasts each log message to multiple loggers.
|
|
func Broadcast(logger ...Logger) Logger {
|
|
var cores []zapcore.Core
|
|
|
|
var singleName string
|
|
|
|
for _, l := range logger {
|
|
dl := l.Desugar()
|
|
|
|
if singleName == "" {
|
|
singleName = dl.Name()
|
|
}
|
|
|
|
if dl.Name() != singleName {
|
|
singleName = "-"
|
|
}
|
|
|
|
cores = append(cores, dl.Core())
|
|
}
|
|
|
|
return zap.New(zapcore.NewTee(cores...)).Sugar().Named(singleName)
|
|
}
|