diff options
Diffstat (limited to 'common/loggers/loggers.go')
-rw-r--r-- | common/loggers/loggers.go | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/common/loggers/loggers.go b/common/loggers/loggers.go index 14c76ae45..c61c55a67 100644 --- a/common/loggers/loggers.go +++ b/common/loggers/loggers.go @@ -240,6 +240,11 @@ func NewBasicLoggerForWriter(t jww.Threshold, w io.Writer) Logger { return newLogger(t, jww.LevelError, w, ioutil.Discard, false) } +// RemoveANSIColours removes all ANSI colours from the given string. +func RemoveANSIColours(s string) string { + return ansiColorRe.ReplaceAllString(s, "") +} + var ( ansiColorRe = regexp.MustCompile("(?s)\\033\\[\\d*(;\\d*)*m") errorRe = regexp.MustCompile("^(ERROR|FATAL|WARN)") |