// Copyright 2019 github.com. All rights reserved. // Use of this source code is governed by github.com. package elastic import ( "fmt" "go.uber.org/zap" ) var logger *zap.Logger // 日志器 // SetLogger 注册日志器 func SetLogger(l *zap.Logger) { logger = l } type ErrorLog struct { } func (p *ErrorLog) Printf(format string, v ...interface{}) { if logger != nil { logger.Error("elastic", zap.String("error", fmt.Sprintf(format, v...))) } } type InfoLog struct { } func (p *InfoLog) Printf(format string, v ...interface{}) { if logger != nil { logger.Info("elastic", zap.String("info", fmt.Sprintf(format, v...))) } } type TraceLog struct { } func (p *TraceLog) Printf(format string, v ...interface{}) { if logger != nil { logger.Debug("elastic", zap.String("debug", fmt.Sprintf(format, v...))) } }