Files
helmfile/pkg/helmexec/log.go
T
AdamClarkandYusuke Kuoka dc6c59dc14 Print command output in line (#1354)
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>
2020-08-29 14:47:22 +09:00

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
}