log

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugLogger = func() API {
		logger, _ := NewLogger(
			WithFileName("go-kit.log"),
			WithMaxSize(3),
			WithMaxBackups(3),
			WithMaxAge(3),
			WithLevel(Dummy),
			WithConsole(true),
		)
		return logger
	}()
	DummyLogger = func() API {
		logger, _ := NewLogger(
			WithFileName("go-kit.log"),
			WithMaxSize(3),
			WithMaxBackups(3),
			WithMaxAge(3),
			WithLevel(Dummy),
			WithConsole(false),
		)
		return logger
	}()
)

Functions

func ErrWrapper added in v0.0.34

func ErrWrapper(err Err) error

Types

type API added in v0.0.34

type API interface {
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
}

func NewLogger

func NewLogger(opts ...Option) (API, error)

type Err added in v0.0.34

type Err int
const (
	UnknownErrCode Err = iota
	IllegalParams
	IllegalKeyType
)

func (Err) String added in v0.0.34

func (i Err) String() string

type Level added in v0.0.34

type Level int64
const (
	UnknownLevel Level = iota
	Dummy
	Debug
	Info
	Warn
	Error
)

func (Level) String added in v0.0.34

func (i Level) String() string

type Meta added in v0.0.34

type Meta struct {
	FileName   string /*日志的名字*/
	MaxSize    int    /*日志大小,单位MB*/
	MaxBackups int    /*日志备份个数*/
	MaxAge     int    /*日志备份时间,单位Day*/
	Level      Level  /*日志级别,可选:none、debug、info、warn、error*/
	Console    bool   /*是否向控制台输出*/
	// contains filtered or unexported fields
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithBuilder added in v0.0.34

func WithBuilder(builder func(*Meta) (API, error)) Option

func WithConsole

func WithConsole(Console bool) Option

func WithFileName

func WithFileName(FileName string) Option

func WithLevel

func WithLevel(Level Level) Option

func WithMaxAge

func WithMaxAge(MaxAge int) Option

func WithMaxBackups

func WithMaxBackups(MaxBackups int) Option

func WithMaxSize

func WithMaxSize(MaxSize int) Option

Jump to

Keyboard shortcuts

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