ref: 93aa6261b4fc8caa74afef97b6304ea35dfd7d0e
parent: acc14b4646d849e09e8da37552d4f4f777d0fce2
author: Bjørn Erik Pedersen <[email protected]>
date: Wed Oct 24 13:22:07 EDT 2018
common/loggers: Remove the ANSI color for the browser error version
--- a/commands/commandeer.go
+++ b/commands/commandeer.go
@@ -104,7 +104,7 @@
m := make(map[string]interface{})
- m["Error"] = errors.New(removeErrorPrefixFromLog(c.logger.Errors.String()))
+ m["Error"] = errors.New(removeErrorPrefixFromLog(c.logger.Errors()))
m["Version"] = hugoVersionString()
fe := herrors.UnwrapErrorWithFileContext(c.buildErr)
--- a/common/loggers/loggers.go
+++ b/common/loggers/loggers.go
@@ -42,14 +42,21 @@
ErrorCounter *jww.Counter
// This is only set in server mode.
- Errors *bytes.Buffer
+ errors *bytes.Buffer
}
+func (l *Logger) Errors() string {
+ if l.errors == nil {
+ return ""
+ }
+ return ansiColorRe.ReplaceAllString(l.errors.String(), "")
+}
+
// Reset resets the logger's internal state.
func (l *Logger) Reset() {
l.ErrorCounter.Reset()
- if l.Errors != nil {
- l.Errors.Reset()
+ if l.errors != nil {
+ l.errors.Reset()
}
}
@@ -108,7 +115,7 @@
return &Logger{
Notepad: jww.NewNotepad(stdoutThreshold, logThreshold, outHandle, logHandle, "", log.Ldate|log.Ltime, listeners...),
ErrorCounter: errorCounter,
- Errors: errorBuff,
+ errors: errorBuff,
}
}