Documentation
¶
Index ¶
- Constants
- Variables
- func InContext(ctx context.Context, log Logger) context.Context
- func SetDefault(fn func() Logger)
- type Helper
- func (h *Helper) Debug(msg string, keyvals ...interface{})
- func (h *Helper) Debugf(format string, a ...interface{})
- func (h *Helper) Error(msg string, keyvals ...interface{})
- func (h *Helper) Errorf(format string, a ...interface{})
- func (h *Helper) Fatal(msg string, keyvals ...interface{})
- func (h *Helper) Fatalf(format string, a ...interface{})
- func (h *Helper) Info(msg string, keyvals ...interface{})
- func (h *Helper) Infof(format string, a ...interface{})
- func (h *Helper) Log(level Level, keyvals ...interface{})
- func (h *Helper) Panic(msg string, keyvals ...interface{})
- func (h *Helper) Panicf(format string, a ...interface{})
- func (h *Helper) Warn(msg string, keyvals ...interface{})
- func (h *Helper) Warnf(format string, a ...interface{})
- func (h *Helper) WithContext(ctx context.Context) *Helper
- type Level
- type Logger
- type Option
- type Valuer
Constants ¶
View Source
const ( DefaultMessageKey = "msg" DefaultLevel = Info )
Variables ¶
View Source
var ( // DefaultCaller is a Valuer that returns the file and line where the Log method was invoked. // It can only be used with log.With. DefaultCaller = Caller(3) )
View Source
var ( // ErrMissingValue is appended to key-values slices with odd length to substitute the missing value. ErrMissingValue = errors.New("(missing value)") )
Functions ¶
func SetDefault ¶
func SetDefault(fn func() Logger)
Types ¶
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
func FromContextAsHelper ¶
FromContextAsHelper 从Context中提取Logger,返回Helper对象。
type Logger ¶
type Logger interface {
Log(level Level, keyvals ...interface{})
}
Logger is the fundamental interface for all log operations. Log creates a log event from keyvals, a variadic sequence of alternating keys and values. Implementations must be safe for concurrent use by multiple goroutines. In particular, any implementation of Logger that appends to keyvals or modifies or retains any of its elements must make a copy first.
func FromContext ¶
FromContext 从Context中提取Logger,如果不存在则返回默认的Logger。
func NewStdLogger ¶
NewStdLogger new a logger implements Logger interface.
Click to show internal directories.
Click to hide internal directories.