-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
main.go
38 lines (32 loc) · 900 Bytes
/
main.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
package main
import (
"github.com/kataras/golog"
)
func main() {
// Let's add a custom level,
//
// It should be starting from level index 6,
// because we have 6 built'n levels (0 is the start index):
// disable,
// fatal,
// error,
// warn,
// info
// debug
// First we create our level to a golog.Level
// in order to be used in the Log functions.
var SuccessLevel golog.Level = 6
// Register our level, just three fields.
golog.Levels[SuccessLevel] = &golog.LevelMetadata{
Name: "success",
Title: "[SUCC]",
ColorCode: 32, // Green
}
// create a new golog logger
myLogger := golog.New()
// set its level to the higher in order to see it
// ("success" is the name we gave to our level)
myLogger.SetLevel("success")
// and finally print a log message with our custom level
myLogger.Logf(SuccessLevel, "This is a success log message with green color")
}