mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-02 19:45:26 +02:00
This is an attempt to log helm exec output as the helm exec command is running. It only prints if the --debug flag is set. Co-authored-by: Yusuke Kuoka <ykuoka@gmail.com>
28 lines
448 B
Go
28 lines
448 B
Go
package helmexec
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
"strings"
|
|
)
|
|
|
|
type logWriterGenerator struct {
|
|
log *zap.SugaredLogger
|
|
}
|
|
|
|
func (g logWriterGenerator) Writer(prefix string) *logWriter {
|
|
return &logWriter{
|
|
log: g.log,
|
|
prefix: prefix,
|
|
}
|
|
}
|
|
|
|
type logWriter struct {
|
|
log *zap.SugaredLogger
|
|
prefix string
|
|
}
|
|
|
|
func (w *logWriter) Write(p []byte) (int, error) {
|
|
w.log.Debugf("%s%s", w.prefix, strings.TrimSpace(string(p)))
|
|
return len(p), nil
|
|
}
|