ZKits Logger Library
About
This package is a library of ZKits project. This is a zero-dependency standard JSON log library that supports structured JSON logs and is compatible with the standard library.
- Flexible and controllable caller report.
- Support 7 log levels.
- Complete log standard library compatibility.
- Chained call, supporting additional log context data.
- Flexible log hook support.
- Custom log formatter support.
Install
go get -u -v github.com/edoger/zkits-logger
Usage
package main
import (
"github.com/edoger/zkits-logger"
)
func main() {
// Creates a logger instance with the specified name.
log := logger.New("test")
// {"level":"info","message":"Something happened.","name":"test","time":"2020-02-20T20:20:20+08:00"}
log.Info("Something happened.")
// {"fields":{"num":1},"level":"info","message":"Something happened.","name":"test","time":"2020-02-20T20:20:20+08:00"}
log.WithField("num", 1).Info("Something happened.")
}