log

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

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

func Error

func Error(args ...interface{})

func Errorf

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

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Info

func Info(args ...interface{})

func Infof

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

func Panic

func Panic(args ...interface{})

func Panicf

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

func SetLevel

func SetLevel(level Level)

func SetLogger

func SetLogger(config *Configuration)

根据日志配置初始化 Logger

func TimeEncoder

func TimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder)

func Warn

func Warn(args ...interface{})

func Warnf

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

Types

type Configuration

type Configuration struct {
	Name  string `xml:"name,omitempty" json:"name,omitempty"`   // name: 日志名称,用于生成日志文件名等,比如 name = "app",则生成的日志文件为 app.log, app_error.log, app_debug.log
	Level Level  `xml:"level,omitempty" json:"level,omitempty"` // level: 日志级别, 可选:DEBUG INFO WARN ERROR
	Path  string `xml:"path,omitempty" json:"path,omitempty"`   // path: 日志路径,比如 ./logs
	Count uint16 `xml:"count,omitempty" json:"count,omitempty"` // count: 日志文件数量
	Size  uint32 `xml:"size,omitempty" json:"size,omitempty"`   // size: 日志文件大小, 单位KB
}

日志配置

func NewDefaultConfiguration

func NewDefaultConfiguration() *Configuration

生成默认日志配置

type Level

type Level uint8
const (
	FATAL Level = iota
	ERROR
	WARN
	INFO
	DEBUG
)

func GetLevelFromStr

func GetLevelFromStr(level string) Level

type LogFile

type LogFile struct {
	DefaultLogFile string
	ErrorLogFile   string
	DebugLogFile   string
}

func GetLogFile

func GetLogFile() LogFile

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})

	Debug(args ...interface{})

	Infof(format string, args ...interface{})

	Info(args ...interface{})

	Warnf(format string, args ...interface{})

	Warn(args ...interface{})

	Errorf(format string, args ...interface{})

	Error(args ...interface{})

	Panicf(format string, args ...interface{})

	Panic(args ...interface{})

	Fatalf(format string, args ...interface{})

	Fatal(args ...interface{})

	SetLevel(level Level)

	GetLogFile() LogFile
}

Logger 接口

Jump to

Keyboard shortcuts

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