@@ -7,6 +7,13 @@ import (
7
7
"os"
8
8
)
9
9
10
+ const (
11
+ ColorReset = "\033 [0m"
12
+ ColorRed = "\033 [31m"
13
+ ColorGreen = "\033 [32m"
14
+ ColorYellow = "\033 [33m"
15
+ )
16
+
10
17
var c * log.Logger
11
18
12
19
func init () {
@@ -24,21 +31,21 @@ func print(s string) {
24
31
25
32
// Info ...
26
33
func Info (format string , args ... any ) {
27
- print ("INFO: " + fmt .Sprintf (format , args ... ))
34
+ print (fmt . Sprintf ( "%sINFO%s: %s" , ColorGreen , ColorReset , fmt .Sprintf (format , args ... ) ))
28
35
}
29
36
30
37
// Warn ...
31
38
func Warn (format string , args ... any ) {
32
- print ("WARN: " + fmt .Sprintf (format , args ... ))
39
+ print (fmt . Sprintf ( "%sWARN%s: %s" , ColorYellow , ColorReset , fmt .Sprintf (format , args ... ) ))
33
40
}
34
41
35
42
// Error ...
36
43
func Error (format string , args ... any ) {
37
- print ("ERROR: " + fmt .Sprintf (format , args ... ))
44
+ print (fmt . Sprintf ( "%sERROR%s: %s" , ColorRed , ColorReset , fmt .Sprintf (format , args ... ) ))
38
45
}
39
46
40
47
// Fatal ...
41
48
func Fatal (format string , args ... any ) {
42
- print ("FATAL: " + fmt .Sprintf (format , args ... ))
49
+ print (fmt . Sprintf ( "%sFATAL%s: %s" , ColorRed , ColorReset , fmt .Sprintf (format , args ... ) ))
43
50
os .Exit (1 )
44
51
}
0 commit comments