logger

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugLevel 调试
	DebugLevel = iota
	// InfoLevel 信息
	InfoLevel
	// WarnLevel 警告
	WarnLevel
	// ErrorLevel 错误
	ErrorLevel
	// PanicLevel panic
	PanicLevel
	// FatalLevel 推出
	FatalLevel
)
View Source
const (
	JsonFormat = 1 // json格式
	TextFormat = 2 // txt文本
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Level       uint8  // 日志级别
	Format      uint8  // 日志格式 1: json,默认格式 2: 文件格式
	Director    string // 日志目录 默认是当前目录下的logs
	RotateType  uint8  // 1:按照日期切分, 默认 2:按照大小切分
	MaxSize     uint32 // 在进行切割之前,日志文件的最大大小(以MB为单位)
	MaxAge      uint32 // 日志最大保留时间 单位:天
	MaxBackups  uint32 // 保留旧文件的最大个数
	Compress    bool   // 是否压缩
	ShowLine    bool   // 是否在日志中输出源码所在的行
	StdoutPrint bool   // 是否输出到控制台
	AdaptType   uint8  // 适配器类型 1: zap(默认类型) 2: zerolog
}

type Fields

type Fields map[string]interface{}

type Logger

type Logger interface {
	Debug(ctx context.Context, args ...interface{})
	Info(ctx context.Context, args ...interface{})
	Warn(ctx context.Context, args ...interface{})
	Error(ctx context.Context, args ...interface{})
	Panic(ctx context.Context, args ...interface{})
	Fatal(ctx context.Context, args ...interface{})

	Debugf(ctx context.Context, format string, args ...interface{})
	Infof(ctx context.Context, format string, args ...interface{})
	Warnf(ctx context.Context, format string, args ...interface{})
	Errorf(ctx context.Context, format string, args ...interface{})
	Panicf(ctx context.Context, format string, args ...interface{})
	Fatalf(ctx context.Context, format string, args ...interface{})

	WithField(key string, value interface{}) Logger
	WithFields(fields Fields) Logger
}

func New

func New(conf *Config) (Logger, error)

Jump to

Keyboard shortcuts

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