-
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) · 764 Bytes
/
example_test.go
File metadata and controls
31 lines (26 loc) · 764 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 gomolconsole
import (
"github.com/aphistic/gomol"
)
// Code for the README example to make sure it still builds!
func Example() {
// Add an io.Writer logger
consoleCfg := NewConsoleLoggerConfig()
consoleLogger, _ := NewConsoleLogger(consoleCfg)
gomol.AddLogger(consoleLogger)
// 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)
}
}