2015-04-27 23:19:51 +00:00
|
|
|
package cli
|
|
|
|
|
|
|
|
// UiWriter is an io.Writer implementation that can be used with
|
|
|
|
// loggers that writes every line of log output data to a Ui at the
|
|
|
|
// Info level.
|
|
|
|
type UiWriter struct {
|
|
|
|
Ui Ui
|
|
|
|
}
|
|
|
|
|
|
|
|
func (w *UiWriter) Write(p []byte) (n int, err error) {
|
|
|
|
n = len(p)
|
2016-01-13 18:40:08 +00:00
|
|
|
if n > 0 && p[n-1] == '\n' {
|
2015-04-27 23:19:51 +00:00
|
|
|
p = p[:n-1]
|
|
|
|
}
|
|
|
|
|
|
|
|
w.Ui.Info(string(p))
|
|
|
|
return n, nil
|
|
|
|
}
|