-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
33 lines (27 loc) · 775 Bytes
/
example_test.go
File metadata and controls
33 lines (27 loc) · 775 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
32
33
package gomolwriter
import (
"os"
"github.com/aphistic/gomol"
)
// Code for the README example to make sure it still builds!
func Example() {
// Add an io.Writer logger
writerCfg := NewWriterLoggerConfig()
writerLogger, _ := NewWriterLogger(os.Stdout, writerCfg)
gomol.AddLogger(writerLogger)
// 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)
}
}