-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
31 lines (26 loc) · 768 Bytes
/
example_test.go
File metadata and controls
31 lines (26 loc) · 768 Bytes
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
package gomoljson
import (
"github.com/aphistic/gomol"
)
// Create a new JSON logger, add it to gomol and log a few messages
func Example() {
// Add a JSON Logger
jsonCfg := NewJSONLoggerConfig("tcp://10.10.10.10:1234")
jsonLogger, _ := NewJSONLogger(jsonCfg)
gomol.AddLogger(jsonLogger)
// Set some global attrs that will be added to all
// messages automatically
gomol.SetAttr("facility", "gomol.example")
gomol.SetAttr("another_attr", 1234)
// Initialize the loggers
gomol.InitLoggers()
defer gomol.ShutdownLoggers()
// Log some debug messages with message-level attrs
// that will be sent only with that message
for idx := 1; idx <= 10; idx++ {
gomol.Dbgm(
gomol.NewAttrs().
SetAttr("msg_attr1", 4321),
"Test message %v", idx)
}
}