log

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevel = iota
	InfoLevel
	WarnLevel
	ErrorLevel
	PanicLevel
	FatalLevel
)

Variables

This section is empty.

Functions

func Debug

func Debug(msg string, fields ...Field)

func Debugf

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

func Error

func Error(msg string, fields ...Field)

func Errorf

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

func Fatal

func Fatal(msg string, fields ...Field)

func Fatalf

func Fatalf(format string, a ...interface{})

func FieldTozapField

func FieldTozapField(fields ...Field) (fds []zap.Field)

func Info

func Info(msg string, fields ...Field)

func Infof

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

func OnInit

func OnInit(config map[string]interface{}, option ...Optionfn) (err error)

func Panic

func Panic(msg string, fields ...Field)

func Panicf

func Panicf(format string, a ...interface{})

func Warn

func Warn(msg string, fields ...Field)

func Warnf

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

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

type ILog

type ILog interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Warn(msg string, fields ...Field)
	Error(msg string, fields ...Field)
	Panic(msg string, fields ...Field)
	Fatal(msg string, fields ...Field)
	Debugf(format string, a ...interface{})
	Infof(format string, a ...interface{})
	Warnf(format string, a ...interface{})
	Errorf(format string, a ...interface{})
	Panicf(format string, a ...interface{})
	Fatalf(format string, a ...interface{})
}

func NewSys

func NewSys(option ...Optionfn) (sys ILog, err error)

type LogEncoder

type LogEncoder int8
const (
	Console LogEncoder = iota
	JSON
)

type LogStrut

type LogStrut interface {
	ToString() (str string)
}

type Logger

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

func (*Logger) Debug

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

func (*Logger) Debugf

func (this *Logger) Debugf(format string, a ...interface{})

func (*Logger) Error

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

func (*Logger) Errorf

func (this *Logger) Errorf(format string, a ...interface{})

func (*Logger) Fatal

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

func (*Logger) Fatalf

func (this *Logger) Fatalf(format string, a ...interface{})

func (*Logger) Info

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

func (*Logger) Infof

func (this *Logger) Infof(format string, a ...interface{})

func (*Logger) Panic

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

func (*Logger) Panicf

func (this *Logger) Panicf(format string, a ...interface{})

func (*Logger) Warn

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

func (*Logger) Warnf

func (this *Logger) Warnf(format string, a ...interface{})

type Loglevel

type Loglevel int8

type Optionfn

type Optionfn func(*Options)

func SetDebugMode

func SetDebugMode(v bool) Optionfn

func SetEncoder

func SetEncoder(v LogEncoder) Optionfn

func SetFileName

func SetFileName(v string) Optionfn

func SetLogMaxAge

func SetLogMaxAge(v int) Optionfn

func SetLogMaxBackups

func SetLogMaxBackups(v int) Optionfn

func SetLogMaxSize

func SetLogMaxSize(v int) Optionfn

func SetLoglayer

func SetLoglayer(v int) Optionfn

func SetLoglevel

func SetLoglevel(v Loglevel) Optionfn

type Options

type Options struct {
	FileName      string     //日志文件名包含
	Loglevel      Loglevel   //日志输出级别
	Debugmode     bool       //是否debug模式
	Encoder       LogEncoder //日志输出样式
	Loglayer      int        //日志堆栈信息打印层级
	LogMaxSize    int        //每个日志文件最大尺寸 单位 M 默认 1024M
	LogMaxBackups int        //最多保留备份个数	默认 10个
	LogMaxAge     int        //文件最多保存多少天 默认 7天
}

Jump to

Keyboard shortcuts

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