Documentation ¶
Index ¶
- Constants
- Variables
- func Debug(a ...interface{})
- func Debugf(format string, a ...interface{})
- func Debugw(keyvals ...interface{})
- func Error(a ...interface{})
- func Errorf(format string, a ...interface{})
- func Errorw(keyvals ...interface{})
- func Fatal(a ...interface{})
- func Fatalf(format string, a ...interface{})
- func Fatalw(keyvals ...interface{})
- func Info(a ...interface{})
- func Infof(format string, a ...interface{})
- func Infow(keyvals ...interface{})
- func Log(level Level, keyvals ...interface{})
- func NewWriter(logger Logger, opts ...WriterOptionFn) io.Writer
- func SetLogger(logger Logger)
- func Value(ctx context.Context, v interface{}) interface{}
- func Warn(a ...interface{})
- func Warnf(format string, a ...interface{})
- func Warnw(keyvals ...interface{})
- type Filter
- type FilterOption
- type Helper
- func (h *Helper) Debug(a ...interface{})
- func (h *Helper) Debugf(format string, a ...interface{})
- func (h *Helper) Debugw(keyvals ...interface{})
- func (h *Helper) Error(a ...interface{})
- func (h *Helper) Errorf(format string, a ...interface{})
- func (h *Helper) Errorw(keyvals ...interface{})
- func (h *Helper) Fatal(a ...interface{})
- func (h *Helper) Fatalf(format string, a ...interface{})
- func (h *Helper) Fatalw(keyvals ...interface{})
- func (h *Helper) Info(a ...interface{})
- func (h *Helper) Infof(format string, a ...interface{})
- func (h *Helper) Infow(keyvals ...interface{})
- func (h *Helper) Log(level Level, keyvals ...interface{})
- func (h *Helper) Warn(a ...interface{})
- func (h *Helper) Warnf(format string, a ...interface{})
- func (h *Helper) Warnw(keyvals ...interface{})
- func (h *Helper) WithContext(ctx context.Context) *Helper
- type Level
- type Logger
- type Option
- type Valuer
- type WriterOptionFn
Constants ¶
const LevelKey = "level"
LevelKey is logger level key.
Variables ¶
var ( // DefaultCaller is a Valuer that returns the file and line. DefaultCaller = Caller(4) // DefaultTimestamp is a Valuer that returns the current wallclock time. DefaultTimestamp = Timestamp(time.RFC3339) )
var DefaultLogger = NewStdLogger(log.Writer())
DefaultLogger is default logger.
var DefaultMessageKey = "msg"
DefaultMessageKey default message key.
Functions ¶
func NewWriter ¶
func NewWriter(logger Logger, opts ...WriterOptionFn) io.Writer
NewWriter return a writer wrapper.
func SetLogger ¶
func SetLogger(logger Logger)
SetLogger should be called before any other log call. And it is NOT THREAD SAFE.
Types ¶
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter is a logger filter.
func NewFilter ¶
func NewFilter(logger Logger, opts ...FilterOption) *Filter
NewFilter new a logger filter.
type FilterOption ¶
type FilterOption func(*Filter)
FilterOption is filter option.
func FilterFunc ¶
func FilterFunc(f func(level Level, keyvals ...interface{}) bool) FilterOption
FilterFunc with filter func.
type Helper ¶
type Helper struct {
// contains filtered or unexported fields
}
Helper is a logger helper.
func (*Helper) Debug ¶
func (h *Helper) Debug(a ...interface{})
Debug logs a message at debug level.
func (*Helper) Debugw ¶
func (h *Helper) Debugw(keyvals ...interface{})
Debugw logs a message at debug level.
func (*Helper) Error ¶
func (h *Helper) Error(a ...interface{})
Error logs a message at error level.
func (*Helper) Errorw ¶
func (h *Helper) Errorw(keyvals ...interface{})
Errorw logs a message at error level.
func (*Helper) Fatal ¶
func (h *Helper) Fatal(a ...interface{})
Fatal logs a message at fatal level.
func (*Helper) Fatalw ¶
func (h *Helper) Fatalw(keyvals ...interface{})
Fatalw logs a message at fatal level.
func (*Helper) Infow ¶
func (h *Helper) Infow(keyvals ...interface{})
Infow logs a message at info level.
type Level ¶
type Level int8
Level is a logger level.
func ParseLevel ¶
ParseLevel parses a level string into a logger Level value.
type Logger ¶
Logger is a logger interface.
type Valuer ¶
Valuer is returns a log value.
type WriterOptionFn ¶
type WriterOptionFn func(w *writerWrapper)
func WithWriteMessageKey ¶
func WithWriteMessageKey(key string) WriterOptionFn
WithWriteMessageKey set writerWrapper helper message key.
func WithWriterLevel ¶
func WithWriterLevel(level Level) WriterOptionFn
WithWriteLevel set writerWrapper level.