go get -u github.com/mushroomsir/logger
- Easy to use
- Display log
FileLine
- Output
JSON
format - Support
KV
syntactic sugar - Improve efficiency
- Output
Err
automatically if err not nil - Standard log level Syslog
- Flexible for custom
- Control output by level
alog.Info("hello world")
alog.Infof("hello world %v", "format")
// Outout:
[2018-10-13T03:05:28.476Z] INFO {"file":"examples/main.go:16","message1":"hello world"}
[2018-10-13T03:05:28.477Z] INFO {"file":"examples/main.go:18","message":"hello world format"}
alog.Info("key", "val")
// Output:
[2018-04-12T14:46:58.088Z] INFO {"file":"main.go:15","Key":"val"}
err := errors.New("x")
if alog.NotNil(err) {
return err
}
// Output:
[2018-04-18T00:34:19.946Z] ERR {"error":"x","file":"main.go:13"}
var err error
if alog.NotNil(err) {
return err
}
// continue code execution
Standard log level Syslog
alog.Debug()
alog.Debugf()
alog.Info()
alog.Infof()
alog.Warning()
alog.Warningf()
...
var blog = pkg.New(os.Stderr, pkg.Options{
EnableJSON: true,
EnableFileLine: true,
TimeFormat: "2006-01-02T15:04:05.999Z",
LogFormat: "[%s] %s %s",
})
alog.SetLevel(pkg.InfoLevel)
All source code is licensed under the MIT License.