-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathcolor.go
45 lines (38 loc) · 857 Bytes
/
color.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package logger
import (
"github.com/0xb10c/memo/config"
)
const prefix = "\033["
const resetAll = prefix + "0m"
const resetFontColor = prefix + "39m"
func colorIsEnabled() bool {
return config.GetBool("log.colorizeOutput")
}
// Red colorizes the input red
func Red(input string) string {
if colorIsEnabled() {
return prefix + "31m" + input + resetFontColor
}
return input
}
// Blue colorizes the input red
func Blue(input string) string {
if colorIsEnabled() {
return prefix + "36m" + input + resetFontColor
}
return input
}
// Yellow colorizes the input red
func Yellow(input string) string {
if colorIsEnabled() {
return prefix + "93m" + input + resetFontColor
}
return input
}
// Dim colorizes the input red
func Dim(input string) string {
if colorIsEnabled() {
return prefix + "2m" + input + prefix + "22m"
}
return input
}