diff options
-rw-r--r-- | pkg/test/testutil/testutil.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/test/testutil/testutil.go b/pkg/test/testutil/testutil.go index fdd416b5e..2b2f95c13 100644 --- a/pkg/test/testutil/testutil.go +++ b/pkg/test/testutil/testutil.go @@ -111,6 +111,30 @@ func (d DefaultLogger) Logf(fmt string, args ...interface{}) { log.Printf(fmt, args...) } +// multiLogger logs to multiple Loggers. +type multiLogger []Logger + +// Name implements Logger.Name. +func (m multiLogger) Name() string { + names := make([]string, len(m)) + for i, l := range m { + names[i] = l.Name() + } + return strings.Join(names, "+") +} + +// Logf implements Logger.Logf. +func (m multiLogger) Logf(fmt string, args ...interface{}) { + for _, l := range m { + l.Logf(fmt, args...) + } +} + +// NewMultiLogger returns a new Logger that logs on multiple Loggers. +func NewMultiLogger(loggers ...Logger) Logger { + return multiLogger(loggers) +} + // Cmd is a simple wrapper. type Cmd struct { logger Logger |