logger

package
v1.0.67 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2022 License: Zlib Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// NDebugLevel ()
	NDebugLevel = int8(-2)

	DebugLevel = int8(zap.DebugLevel)
	InfoLevel  = int8(zap.InfoLevel)
	// WarnLevel defines warn log level.
	WarnLevel = int8(zap.WarnLevel)
	// ErrorLevel defines error log level.
	ErrorLevel = int8(zap.ErrorLevel)
	// FatalLevel defines fatal log level.
	FatalLevel = int8(zap.FatalLevel)
	// PanicLevel defines panic log level.
	PanicLevel = int8(zap.PanicLevel)
)

对外进行统一的封装

Variables

This section is empty.

Functions

func Byte2

func Byte2(level int8, b []byte) string

func Configure

func Configure(config Config, opts ...OptionFunc) error

func Context added in v0.5.27

func Context() *zap.Logger

func Debug

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

func Error

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

Error defines error log level.

func Fatal

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

Fatal defines fatal log level.

func Info

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

Info defines info log level.

func NDebug

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

NDebug *

正式环境,不输出日志

func Panic

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

Panic (format string, args ...interface{}) { defines panic log level.

func Recover added in v1.0.64

func Recover(callerSkip int, err interface{})

Recover defines error log level.

func Warn

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

Warn defines warn log level.

func ZLog added in v1.0.40

func ZLog(info string) zap.Field

func ZLogf added in v1.0.40

func ZLogf(format string, args ...any) zap.Field

Types

type Config

type Config struct {
	Level int8 `json:"level" yaml:"level" xml:"level"`

	// Enable console logging
	ConsoleEnabled bool `json:"console" yaml:"console" xml:"console"`
	// FileLoggingEnabled makes the framework log to a file
	// the fields below can be skipped if this value is false!
	FileEnabled bool         `json:"fileEnabled" yaml:"fileEnabled" xml:"fileEnabled"`
	FileFormat  string       `json:"fileFormat" yaml:"fileFormat" xml:"fileFormat"`
	FilePath    string       `json:"filePath" yaml:"filePath" xml:"filePath"`
	FileConfigs []FileConfig `json:"fileConfigs" yaml:"fileConfigs" xml:"fileConfigs"`
}

type FileConfig added in v1.0.62

type FileConfig struct {
	MinLevel int8 `json:"minLevel" yaml:"minLevel" xml:"minLevel"`
	MaxLevel int8 `json:"maxLevel" yaml:"maxLevel" xml:"maxLevel"`

	// Name is the name of the logfile which will be placed inside the directory
	Name string `json:"name" yaml:"name" xml:"name"`
	// MaxSize the max size in MB of the logfile before it's rolled
	MaxSize int `json:"maxSize" yaml:"maxSize" xml:"maxSize"`
	// MaxBackups the max number of rolled files to keep
	MaxBackups int `json:"backupNum" yaml:"backupNum" xml:"backupNum"`
	// MaxAge the max age in days to keep a logfile
	MaxAge int `json:"days" json:"days" xml:"days"`
}

type OptionFunc added in v1.0.66

type OptionFunc func(fileConfig *FileConfig)

Jump to

Keyboard shortcuts

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