1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.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...)))
- }
- }
|