-
Notifications
You must be signed in to change notification settings - Fork 1
/
modules.go
70 lines (56 loc) · 1.39 KB
/
modules.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
65
66
67
68
69
70
/*
Application modules are test permutations testing various rlog output modules.
*/
package main
import (
"github.com/brsc/rlog"
"github.com/brsc/rlog/file"
"github.com/brsc/rlog/stdout"
"github.com/brsc/rlog/syslog"
"strings"
)
func main() {
//Setup syslog module
syslogModule, err := syslog.NewLocalSyslogLogger()
if err != nil {
panic("Getting syslog logger instance failed")
}
//Setup file logger
fileModule, err := file.NewFileLogger("test.txt", true, true)
if err != nil {
panic("Getting file logger instance failed: " + err.Error())
}
rlog.EnableModule(syslogModule)
rlog.EnableModule(fileModule)
rlog.EnableModule(stdout.NewStdoutLogger(true))
rlog.Start(rlog.GetDefaultConfig())
defer rlog.Flush()
//Test all the different log levels
rlog.Debug("debug log entry")
rlog.Info("info log entry")
rlog.Error("error log entry")
rlog.Fatal("fatal log entry")
//Generate a couple of IDs and log it
ids := ""
for i := 0; i < 10; i++ {
ids += rlog.GenerateID() + ", "
}
rlog.Info("IDs: %s", ids)
//A deeply nested stack trace
rlog.Debug("---------------------------")
level1()
rlog.Debug("---------------------------")
//A very long log message
rlog.Debug(strings.Repeat("hello Rightscale", 1000))
//All done
rlog.Debug("Test permutations completed")
}
func level1() {
level2()
}
func level2() {
level3()
}
func level3() {
rlog.Error("nested function call")
}