-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathconsole.go
64 lines (55 loc) · 1.14 KB
/
console.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package console
import (
"fmt"
"os"
"regtool/env"
"strings"
)
var Color = struct {
Reset string
Red string
Green string
Yellow string
Blue string
Purple string
Cyan string
White string
}{
Reset: "\033[0m",
Red: "\033[31m",
Green: "\033[32m",
Yellow: "\033[33m",
Blue: "\033[34m",
Purple: "\033[35m",
Cyan: "\033[36m",
White: "\033[37m",
}
func Println(color string, messages ...string) {
message := strings.Join(messages, " ")
fmt.Println(color + message + Color.Reset)
}
func Print(color string, messages ...string) {
message := strings.Join(messages, " ")
fmt.Print(color + message + Color.Reset)
}
func Printf(color string, format string, a ...interface{}) {
fmt.Printf(color+format+Color.Reset, a...)
}
func Success(messages ...string) {
Println(Color.Green, messages...)
}
func Error(messages ...string) {
Println(Color.Red, messages...)
}
func Warning(messages ...string) {
Println(Color.Yellow, messages...)
}
func Info(messages ...string) {
Println(Color.Blue, messages...)
}
func Debug(messages ...string) {
if os.Getenv(env.GO_MODE) != env.DEBUG {
return
}
Println(Color.Purple, messages...)
}