# README
xLogger
zap based logger
install
go get github.com/clearcodecn/log@latest
Usage
import "github.com/clearcodecn/log"
- add hooks to logger and inject log fields to logger.
log.AddHook(func(ctx context.Context) Field {
reqid, ok := ctx.Value("reqid").(string)
if !ok {
return Field{}
}
return Any("reqid", reqid)
})
ctx := context.WithValue(context.Background(), "reqid", "123456")
log.Logger(ctx).Info("help me")
- gin middleware
var conf xlogger.GinLogConfigure
conf.SkipPrefix("/static","/favico.ico")
conf.AddHeaderKeys("reqid")
gin.Use(log.GinLog(conf))
- gorm middleware
db := gorm.New()
db.Use(log.NewLoggerPlugin())
# Functions
AddHook unsafe add global hook, it should be called at init functions.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
GinLog http server Middleware Logger.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
ReqId set context with request id in all log trace.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
# Constants
gorm log.
# Structs
No description provided by the author
GinLogConfigure http server log settings.