utils

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: May 23, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWriter

func NewWriter(opts WriterOptions) (io.Writer, error)

Types

type CutRule

type CutRule int

CutRule 日志切割规则

const (
	CutByYear   CutRule = iota + 1 // 按照年切割
	CutByMonth                     // 按照月切割
	CutByDay                       // 按照日切割
	CutByHour                      // 按照时切割
	CutByMinute                    // 按照分切割
	CutBySecond                    // 按照秒切割
)

func (CutRule) String

func (c CutRule) String() string

type Format

type Format int

Format 日志输出格式

const (
	TextFormat Format = iota // 文本格式
	JsonFormat               // JSON格式
)

func (Format) String

func (f Format) String() string

type Level

type Level int

Level 日志级别

const (
	NoneLevel  Level = iota // NONE
	DebugLevel              // DEBUG
	InfoLevel               // INFO
	WarnLevel               // WARN
	ErrorLevel              // ERROR
	FatalLevel              // FATAL
	PanicLevel              // PANIC
)

func ParseLevel

func ParseLevel(level string) Level

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	// Debug 打印调试日志
	Debug(a ...interface{})
	// Debugf 打印调试模板日志
	Debugf(format string, a ...interface{})
	// Info 打印信息日志
	Info(a ...interface{})
	// Infof 打印信息模板日志
	Infof(format string, a ...interface{})
	// Warn 打印警告日志
	Warn(a ...interface{})
	// Warnf 打印警告模板日志
	Warnf(format string, a ...interface{})
	// Error 打印错误日志
	Error(a ...interface{})
	// Errorf 打印错误模板日志
	Errorf(format string, a ...interface{})
	// Fatal 打印致命错误日志
	Fatal(a ...interface{})
	// Fatalf 打印致命错误模板日志
	Fatalf(format string, a ...interface{})
	// Panic 打印Panic日志
	Panic(a ...interface{})
	// Panicf 打印Panic模板日志
	Panicf(format string, a ...interface{})
}

type WriterOptions

type WriterOptions struct {
	Path    string
	Level   Level
	MaxAge  time.Duration
	MaxSize int64
	CutRule CutRule
}

Jump to

Keyboard shortcuts

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