log

package
v0.0.0-...-6bcf8dd Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LevelDebug = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelPanic
	LevelFatal
	LevelOff // 日志关闭
)

Variables

This section is empty.

Functions

func SetCallDepth

func SetCallDepth(depth int)

func SetLevel

func SetLevel(level Level)

设置所有Logger的level

func SetLogFunc

func SetLogFunc(f writeLogFunc)

func SwitchLog

func SwitchLog(f int32)

总开关

Types

type Encoder

type Encoder interface {
	EncodeBool(key string, val bool)
	EncodeFloat64(key string, val float64)
	EncodeInt(key string, val int)
	EncodeInt64(key string, val int64)
	EncodeDuration(key string, val time.Duration)
	EncodeUint(key string, val uint)
	EncodeUint64(key string, val uint64)
	EncodeString(key string, val string)
	EncodeObject(key string, val interface{})
	EncodeType(key string, val reflect.Type)
}

type Field

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

func Bool

func Bool(key string, val bool) Field

Bool constructs a Field with the given key and value.

func Duration

func Duration(key string, val time.Duration) Field

Duration constructs a Field with the given key and value.

func Error

func Error(err error) Field

Error constructs a Field that lazily stores err.Error() under the key "error". If passed a nil error, the field is skipped.

func Float64

func Float64(key string, val float64) Field

Float64 constructs a Field with the given key and value.

func Int

func Int(key string, val int) Field

Int constructs a Field with the given key and value. Marshaling ints is lazy.

func Int64

func Int64(key string, val int64) Field

Int64 constructs a Field with the given key and value.

func Message

func Message(val interface{}) Field

Message constructs a field to store the message under the key message

func Object

func Object(key string, val interface{}) Field

Object constructs a field with the given key and an arbitrary object.

func Stack

func Stack() Field

Stack constructs a Field that stores a stacktrace under the key "stacktrace".

This is eager and therefore an expensive operation.

func String

func String(key string, val string) Field

String constructs a Field with the given key and value.

func Stringer

func Stringer(key string, val fmt.Stringer) Field

Stringer constructs a Field with the given key and the output of the value's String method. The String is not evaluated until encoding.

func Time

func Time(key string, val time.Time) Field

Time constructs a Field with the given key and value. It represents a time.Time as a floating-point number of seconds since the Unix epoch.

func TypeOf

func TypeOf(key string, val interface{}) Field

TypeOf constructs a field with the given key and an arbitrary object that will log the type information lazily.

func Uint

func Uint(key string, val uint) Field

Uint constructs a Field with the given key and value.

func Uint64

func Uint64(key string, val uint64) Field

Uint64 constructs a Field with the given key and value.

func (Field) Encode

func (f Field) Encode(enc Encoder)

Encode encodes a field to a type safe val via the encoder.

type Level

type Level int
var (
	DefaultLogLevel  Level = LevelDebug
	DefaultCallDepth       = 4
)

type Logger

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

func New

func New(name string, context ...Field) *Logger

func (*Logger) Context

func (l *Logger) Context() []Field

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...Field)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

func (*Logger) Level

func (l *Logger) Level() Level

func (*Logger) Name

func (l *Logger) Name() string

func (*Logger) OutWriter

func (l *Logger) OutWriter() string

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...Field)

func (*Logger) SetLevel

func (l *Logger) SetLevel(level Level)

func (*Logger) SetOutWriter

func (l *Logger) SetOutWriter(writername string)

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL