hugo

Unnamed repository; edit this file 'description' to name the repository.

git clone git://git.shimmy1996.com/hugo.git
commit 93aa6261b4fc8caa74afef97b6304ea35dfd7d0e
parent acc14b4646d849e09e8da37552d4f4f777d0fce2
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date:   Wed, 24 Oct 2018 17:22:07 +0200

common/loggers: Remove the ANSI color for the browser error version

Diffstat:
Mcommands/commandeer.go | 2+-
Mcommon/loggers/loggers.go | 15+++++++++++----
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/commands/commandeer.go b/commands/commandeer.go
@@ -104,7 +104,7 @@ func (c *commandeer) getErrorWithContext() interface{} {
 
 	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)
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go
@@ -42,14 +42,21 @@ type Logger struct {
 	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 @@ func newLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle
 	return &Logger{
 		Notepad:      jww.NewNotepad(stdoutThreshold, logThreshold, outHandle, logHandle, "", log.Ldate|log.Ltime, listeners...),
 		ErrorCounter: errorCounter,
-		Errors:       errorBuff,
+		errors:       errorBuff,
 	}
 }