Gomol (Go Multi-Output Logger) is an MIT-licensed Go logging library. The documentation and test coverage at this point is thin but will be improving over time.
- Multiple outputs at the same time
The recommended way to install is via http://gopkg.in
go get gopkg.in/aphistic/gomol.v0
...
import "gopkg.in/aphistic/gomol.v0"
Gomol can also be installed the standard way as well
go get github.com/aphistic/gomol
...
import "github.com/aphistic/gomol"
For brevity a lot of error checking has been omitted, be sure you do your checks!
This is a super basic example of adding a number of loggers and then logging a few messages:
package main
import (
"github.com/aphistic/gomol"
)
func main() {
consoleCfg := gomol.NewConsoleLoggerConfig()
gomol.AddLogger(gomol.NewConsoleLogger(consoleCfg))
gomol.AddLogger(gomol.NewLogglyLogger("1234"))
gelfCfg := gomol.NewGelfLoggerConfig()
gelfCfg.Hostname = "localhost"
gelfCfg.Port = 12201
gomol.AddLogger(gomol.NewGelfLogger(gelfCfg))
gomol.SetAttr("facility", "gomol.example")
gomol.SetAttr("another_attr", 1234)
gomol.InitLoggers()
defer gomol.ShutdownLoggers()
for idx := 1; idx <= 10; idx {
gomol.Dbgm(map[string]interface{}{
"msg_attr1": 4321,
}, "Test message %v", idx)
}
}