Skip to content

Commit

Permalink
common/loggers: Remove the ANSI color for the browser error version
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Oct 24, 2018
1 parent acc14b4 commit 93aa626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion commands/commandeer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 11 additions & 4 deletions common/loggers/loggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down Expand Up @@ -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,
}
}

Expand Down

0 comments on commit 93aa626

Please sign in to comment.