Documentation
¶
Index ¶
- func InitContext(ctx context.Context, traceID string) context.Context
- func NewTraceID() string
- func Register(l Logger)
- func WithValue(ctx context.Context, field string, value interface{})
- type ContextHook
- type Field
- type Logger
- type NopLogger
- func (l *NopLogger) Debug(msg string, fields ...Field)
- func (l *NopLogger) Error(msg string, fields ...Field)
- func (l *NopLogger) Fatal(msg string, fields ...Field)
- func (l *NopLogger) Info(msg string, fields ...Field)
- func (l *NopLogger) Warn(msg string, fields ...Field)
- func (l *NopLogger) WithCtx(ctx context.Context) Logger
- func (l *NopLogger) WithField(field ...Field) Logger
- func (l *NopLogger) WithSkip(skip int) Logger
- type ZapLogger
- func (z *ZapLogger) Debug(msg string, fields ...Field)
- func (z *ZapLogger) Error(msg string, fields ...Field)
- func (z *ZapLogger) Fatal(msg string, fields ...Field)
- func (z *ZapLogger) Info(msg string, fields ...Field)
- func (z *ZapLogger) Warn(msg string, fields ...Field)
- func (z *ZapLogger) WithCtx(ctx context.Context) Logger
- func (z *ZapLogger) WithField(field ...Field) Logger
- func (z *ZapLogger) WithSkip(skip int) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewTraceID ¶
func NewTraceID() string
Types ¶
type ContextHook ¶
type ContextHook struct{}
func NewContextHook ¶
func NewContextHook() *ContextHook
func (*ContextHook) Fire ¶
func (hook *ContextHook) Fire(entry *logrus.Entry) error
Fire 会在日志输出之前调用,向日志条目中添加从 context 中提取的键值对
func (*ContextHook) Levels ¶
func (hook *ContextHook) Levels() []logrus.Level
Levels 定义 Hook 适用的日志级别
type Logger ¶
type Logger interface {
Debug(msg string, fields ...Field)
Info(msg string, fields ...Field)
Warn(msg string, fields ...Field)
Error(msg string, fields ...Field)
Fatal(msg string, fields ...Field)
// WithCtx returns a new Logger with the given context.
// highly recommended
WithCtx(ctx context.Context) Logger
WithField(field ...Field) Logger
WithSkip(skip int) Logger
}
func NewLogrusLogger ¶
func NewLogrusLogger() Logger
func NewZapLogger ¶
Click to show internal directories.
Click to hide internal directories.