log

package
Version: v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const LevelKey = "level"

Variables

View Source
var LevelMap = map[Level]string{
	LevelDebug: "DEBUG",
	LevelInfo:  "INFO",
	LevelWarn:  "WARN",
	LevelError: "ERROR",
}

LevelMap .

Functions

func Value

func Value(v interface{}) interface{}

Types

type Helper

type Helper struct {
	// contains filtered or unexported fields
}

func NewHelper

func NewHelper(name string, logger Logger) *Helper

func (*Helper) Debug

func (h *Helper) Debug(a ...interface{})

Debug logs a message at debug level.

func (*Helper) Debugf

func (h *Helper) Debugf(format string, a ...interface{})

Debugf logs a message at debug level.

func (*Helper) Debugw

func (h *Helper) Debugw(pairs ...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) Errorf

func (h *Helper) Errorf(format string, a ...interface{})

Errorf logs a message at error level.

func (*Helper) Errorw

func (h *Helper) Errorw(pairs ...interface{})

Errorw logs a message at error level.

func (*Helper) Info

func (h *Helper) Info(a ...interface{})

Info logs a message at info level.

func (*Helper) Infof

func (h *Helper) Infof(format string, a ...interface{})

Infof logs a message at info level.

func (*Helper) Infow

func (h *Helper) Infow(pairs ...interface{})

Infow logs a message at info level.

func (*Helper) Warn

func (h *Helper) Warn(a ...interface{})

Warn logs a message at warn level.

func (*Helper) Warnf

func (h *Helper) Warnf(format string, a ...interface{})

Warnf logs a message at warnf level.

func (*Helper) Warnw

func (h *Helper) Warnw(pairs ...interface{})

Warnw logs a message at warnf level.

type Level

type Level int8
const (
	// LevelDebug is logger debug level.
	LevelDebug Level = iota
	// LevelInfo is logger info level.
	LevelInfo
	// LevelWarn is logger warn level.
	LevelWarn
	// LevelError is logger error level.
	LevelError
)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	Print(pairs ...interface{})
}
var (
	// DefaultLogger is default logger.
	DefaultLogger Logger = NewStdLogger(log.Writer())
)

func Debug

func Debug(log Logger) Logger

Debug returns a debug logger.

func Error

func Error(log Logger) Logger

Error returns a error logger.

func Info

func Info(log Logger) Logger

Info returns a info logger.

func NewStdLogger

func NewStdLogger(w io.Writer) Logger

func Warn

func Warn(log Logger) Logger

Warn return a warn logger.

func With

func With(l Logger, a ...interface{}) Logger

func Wrap

func Wrap(logs ...Logger) Logger

Wrap wraps multi logger.

type Valuer

type Valuer func() interface{}

func Caller

func Caller(depth int) Valuer

type Verbose

type Verbose struct {
	// contains filtered or unexported fields
}

Verbose is a verbose type that implements Logger Print.

func NewVerbose

func NewVerbose(log Logger, level Level) Verbose

NewVerbose new a verbose with level.

func (Verbose) Enabled

func (v Verbose) Enabled(level Level) bool

Enabled will return true if this log level is enabled, guarded by the value of v.

func (Verbose) Print

func (v Verbose) Print(a ...interface{})

Print is equivalent to the Print function, guarded by the value of v.

func (Verbose) V

func (v Verbose) V(level Level) Verbose

V reports whether verbosity at the call site is at least the requested level.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL