-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlog.go
48 lines (41 loc) · 955 Bytes
/
log.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
package main
import (
"fmt"
"strings"
"github.com/golang-demos/chalk"
)
func getIndent(depth int) string {
return strings.Repeat(" ", depth)
}
func Info(depth int, args ...interface{}) {
fmt.Print(getIndent(depth))
fmt.Print(chalk.BlueLight().Bold())
fmt.Print("[INFO]")
fmt.Print(chalk.Reset())
fmt.Print(" ")
fmt.Println(args...)
}
func Warn(depth int, args ...interface{}) {
fmt.Print(getIndent(depth))
fmt.Print(chalk.YellowLight().Bold())
fmt.Print("[WARN]")
fmt.Print(chalk.Reset())
fmt.Print(" ")
fmt.Println(args...)
}
func Success(depth int, args ...interface{}) {
fmt.Print(getIndent(depth))
fmt.Print(chalk.GreenLight().Bold())
fmt.Print("[SUCCESS]")
fmt.Print(chalk.Reset())
fmt.Print(" ")
fmt.Println(args...)
}
func Error(depth int, args ...interface{}) {
fmt.Print(getIndent(depth))
fmt.Print(chalk.RedLight().Bold())
fmt.Print("[ERROR]")
fmt.Print(chalk.Reset())
fmt.Print(" ")
fmt.Println(args...)
}