summaryrefslogtreecommitdiffstats
path: root/common/terminal
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-24 18:32:30 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2018-10-28 14:16:23 +0100
commit1c7b7b4ef293aa133e5b55f3ebb2d37d8839532f (patch)
tree6f26bf84bf92339fcf67449f6db4c355b2d97642 /common/terminal
parent1ad117cbe2903aa9d029f90750acf633eb2a51a2 (diff)
common/loggers: Add color to ERROR and WARN
Fixes #4414
Diffstat (limited to 'common/terminal')
-rw-r--r--common/terminal/colors.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/common/terminal/colors.go b/common/terminal/colors.go
index 691173ea8..a02d016d9 100644
--- a/common/terminal/colors.go
+++ b/common/terminal/colors.go
@@ -23,7 +23,9 @@ import (
)
const (
- noticeColor = "\033[1;36m%s\033[0m"
+ errorColor = "\033[1;31m%s\033[0m"
+ warningColor = "\033[0;33m%s\033[0m"
+ noticeColor = "\033[1;36m%s\033[0m"
)
// IsTerminal return true if the file descriptor is terminal and the TERM
@@ -38,6 +40,16 @@ func Notice(s string) string {
return colorize(s, noticeColor)
}
+// Error colorizes the string in a colour that grabs attention.
+func Error(s string) string {
+ return colorize(s, errorColor)
+}
+
+// Warning colorizes the string in a colour that warns.
+func Warning(s string) string {
+ return colorize(s, warningColor)
+}
+
// colorize s in color.
func colorize(s, color string) string {
s = fmt.Sprintf(color, doublePercent(s))