Documentation ¶
Index ¶
- func AddGlobalFields(field string)
- func ClearGlobalFields()
- func FullCallerEncoder() func(file string, line int) string
- func GetGlobalFields() []string
- func GetGoroutineID() uint64
- func GetZeroLogger() *zerolog.Logger
- func LowercaseLevelEncoder() func(l zerolog.Level) string
- func ResetGlobalMdcAdapter()
- func SetGlobalFields(fields []string)
- func SetLogger(configItems ...ConfigItem) gin.HandlerFunc
- func ShortCallerEncoder() func(file string, line int) string
- func TrimmedPath(file string) string
- func UppercaseLevelEncoder() func(l zerolog.Level) string
- func Z() *zerolog.Logger
- type Config
- type ConfigItem
- type MDCHook
- type MdcAdapter
- func (m *MdcAdapter) Count() int
- func (m *MdcAdapter) Get(key string) (interface{}, bool)
- func (m *MdcAdapter) GetString(key string) string
- func (m *MdcAdapter) Has(key string) bool
- func (m *MdcAdapter) IsEmpty() bool
- func (m *MdcAdapter) Keys() []string
- func (m *MdcAdapter) Remove(key string)
- func (m *MdcAdapter) Set(key string, value interface{})
- func (m *MdcAdapter) SetIfAbsent(key string, value interface{}) bool
- func (m *MdcAdapter) SetMap(data map[string]interface{})
- type Overlog
- func (o *Overlog) Debug() *zerolog.Event
- func (o *Overlog) Debugf(format string, args ...interface{})
- func (o *Overlog) Error() *zerolog.Event
- func (o *Overlog) Errorf(format string, args ...interface{})
- func (o *Overlog) Fatal(args ...interface{})
- func (o *Overlog) Fatalf(format string, args ...interface{})
- func (o *Overlog) Info() *zerolog.Event
- func (o *Overlog) Infof(format string, args ...interface{})
- func (o *Overlog) Log(args ...interface{})
- func (o *Overlog) Logf(format string, args ...interface{})
- func (o *Overlog) ODebug(args ...interface{})
- func (o *Overlog) OError(args ...interface{})
- func (o *Overlog) OInfo(args ...interface{})
- func (o *Overlog) OPanic(args ...interface{})
- func (o *Overlog) Panic() *zerolog.Event
- func (o *Overlog) Panicf(format string, args ...interface{})
- func (o *Overlog) Print(args ...interface{})
- func (o *Overlog) Printf(format string, args ...interface{})
- func (o *Overlog) Trace(args ...interface{})
- func (o *Overlog) Tracef(format string, args ...interface{})
- func (o *Overlog) Warn(args ...interface{})
- func (o *Overlog) Warnf(format string, args ...interface{})
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddGlobalFields ¶
func AddGlobalFields(field string)
func ClearGlobalFields ¶
func ClearGlobalFields()
func GetGlobalFields ¶
func GetGlobalFields() []string
func GetGoroutineID ¶
func GetGoroutineID() uint64
func GetZeroLogger ¶
func LowercaseLevelEncoder ¶
这个为什么叫Lowercase呢,默认就是小写?
func ResetGlobalMdcAdapter ¶
func ResetGlobalMdcAdapter()
func SetGlobalFields ¶
func SetGlobalFields(fields []string)
func SetLogger ¶
func SetLogger(configItems ...ConfigItem) gin.HandlerFunc
func UppercaseLevelEncoder ¶
Types ¶
type ConfigItem ¶
type ConfigItem interface {
// contains filtered or unexported methods
}
func SetAppId ¶
func SetAppId(appId string) ConfigItem
func SetRequestIdKey ¶
func SetRequestIdKey(requestIdKey string) ConfigItem
func SetSessionid ¶
func SetSessionid(sessionIdKey string) ConfigItem
func SetUserIdKey ¶
func SetUserIdKey(userIdKey string) ConfigItem
type MdcAdapter ¶
func InitGlobalMdcAdapter ¶
func InitGlobalMdcAdapter() *MdcAdapter
func MDC ¶
func MDC() *MdcAdapter
func (*MdcAdapter) Count ¶
func (m *MdcAdapter) Count() int
func (*MdcAdapter) Get ¶
func (m *MdcAdapter) Get(key string) (interface{}, bool)
func (*MdcAdapter) GetString ¶
func (m *MdcAdapter) GetString(key string) string
func (*MdcAdapter) Has ¶
func (m *MdcAdapter) Has(key string) bool
func (*MdcAdapter) IsEmpty ¶
func (m *MdcAdapter) IsEmpty() bool
func (*MdcAdapter) Keys ¶
func (m *MdcAdapter) Keys() []string
func (*MdcAdapter) Remove ¶
func (m *MdcAdapter) Remove(key string)
func (*MdcAdapter) Set ¶
func (m *MdcAdapter) Set(key string, value interface{})
func (*MdcAdapter) SetIfAbsent ¶
func (m *MdcAdapter) SetIfAbsent(key string, value interface{}) bool
func (*MdcAdapter) SetMap ¶
func (m *MdcAdapter) SetMap(data map[string]interface{})
type Overlog ¶
type Overlog struct {
// contains filtered or unexported fields
}
func NewDefault ¶
func NewDefault() *Overlog
func (*Overlog) Debug ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().ODebug("hello world")
Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Debugf ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Debugf("hello %s", "world")
Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Error ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().OError("hello world")
Output: {"level":"error","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Errorf ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Errorf("hello %s", "world")
Output: {"level":"error","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Info ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().OInfo("hello world")
Output: {"level":"info","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Infof ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Infof("hello %s", "world")
Output: {"level":"info","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Log ¶
func (o *Overlog) Log(args ...interface{})
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Log("hello world")
Output: {"x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Logf ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Logf("hello %s", "world")
Output: {"x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Print ¶
func (o *Overlog) Print(args ...interface{})
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Print("hello world")
Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Printf ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Printf("hello %s", "world")
Output: {"level":"debug","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Trace ¶
func (o *Overlog) Trace(args ...interface{})
这么封装就失去了原本的用法
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Trace("hello world")
Output: {"level":"trace","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Tracef ¶
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Tracef("hello %s", "world")
Output: {"level":"trace","x-correlation-id":"1234","message":"hello world"}
func (*Overlog) Warn ¶
func (o *Overlog) Warn(args ...interface{})
Example ¶
New(zerolog.New(os.Stdout)) MDC().Set("x-correlation-id", "1234") AddGlobalFields("x-correlation-id") Log().Warn("hello world")
Output: {"level":"warn","x-correlation-id":"1234","message":"hello world"}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.