/
main.go
64 lines (47 loc) · 1.49 KB
/
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
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 main
import (
"github.com/AndrewDonelson/golog"
)
func doLogs() {
method := "doLogs"
golog.Log.Trace(method, "main.go", 7)
golog.Log.SetFunction(method)
// Debug
golog.Log.Debug("This is Debug message!")
// Show the info
golog.Log.Info("This is Info message, Fatal & Panic skipped!")
// Notice
golog.Log.Notice("This is Notice message!")
// Show the success
golog.Log.Success("This is Success message!")
// Give the Warning
golog.Log.Warning("This is Warning message!")
// Show the error
golog.Log.Error("This is Error message!")
// RAW log
golog.Log.Print("This is RAW message!")
// PrettyPrint log
golog.Log.Print(golog.PrettyPrint(golog.Log.Options))
golog.Log.Trace("This is Trace message!", "main.go", 13)
// Fatally log (skip) halting progam
// golog.Log.Fatal("This is Fatal message!")
}
func main() {
// Get the instance for logger class
// Third option is optional and is instance of type io.Writer, defaults to os.Stderr
println("\nDevelopment Output:")
golog.Log.SetModuleName("dev-example")
golog.Log.SetEnvironment(golog.EnvDevelopment)
doLogs()
println("\nTest/QA Output:")
golog.Log.SetModuleName("qa-example")
golog.Log.SetEnvironment(golog.EnvQuality)
doLogs()
println("\nProduction Output: as Log")
golog.Log.SetModuleName("prod-example")
golog.Log.SetEnvironment(golog.EnvProduction)
doLogs()
println("\nProduction Output: as JSON")
golog.Log.UseJSONForProduction()
doLogs()
}