logger

package
v0.0.0-...-806cc7c Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2025 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TraceLevel = "TRACE"
	DebugLevel = "DEBUG"
	InfoLevel  = "INFO"
	WarnLevel  = "WARN"
	ErrorLevel = "ERROR"
	FatalLevel = "FATAL"

	RollingPolicyTime        = "time"
	RollingPolicySize        = "size"
	RollingPolicyTimeAndSize = "timeAndSize"
	RollingPolicyClose       = "close"
)

Variables

This section is empty.

Functions

func Debug

func Debug(text string, v ...interface{})

func Error

func Error(text string, v ...interface{})

func Fatal

func Fatal(text string, v ...interface{})

func Info

func Info(text string, v ...interface{})

func InitLogger

func InitLogger(config *Config)

func Trace

func Trace(text string, v ...interface{})

func Warn

func Warn(text string, v ...interface{})

Types

type Appender

type Appender interface {
	// contains filtered or unexported methods
}

type Config

type Config struct {
	Level          string `yaml:"level"`             // 日志级别
	EnableTrace    string `yaml:"trace"`             // 是否开启Trace, True/False。默认False
	QueueLength    int    `yaml:"queueLength"`       // 缓存队列大小,默认50000
	AppenderNum    int    `yaml:"appenderNum"`       // 日志输出器数量,默认2
	TimeFormat     string `yaml:"timeFormat"`        // 日志时间输出格式
	Path           string `yaml:"path"`              // 日志存储目录
	FileName       string `yaml:"fileName"`          // 日志文件名称
	RollingPolicy  string `yaml:"rollingPolicy"`     // 日志切分策略。
	MaxSize        string `yaml:"maxSize"`           // 1MB, 10KB, 1GB
	MaxTime        string `yaml:"maxTime"`           // 60s, 60m, 1h
	Compress       string `yaml:"compress"`          // 是否对备份日志进行压缩, True/False。默认True
	CleanBackup    string `yaml:"cleanBackup"`       // 是否清理备份日志文件, True/False。默认True
	BackupMaxCount int    `yaml:"backupMaxCount"`    // 保留备份日志文件最大数量。log.cleanBackup=true生效,默认10
	BackupMaxDisk  string `yaml:"backupMaxDiskSize"` // 保留备份日志文件磁盘最大大小, 1MB, 10KB, 1GB。log.cleanBackup=true生效,默认1GB
	EnableColor    string `yaml:"color"`             // 是否开启颜色
}

type ILog

type ILog interface {
	Trace(text string, v ...interface{})
	Debug(text string, v ...interface{})
	Info(text string, v ...interface{})
	Warn(text string, v ...interface{})
	Error(text string, v ...interface{})
	Fatal(text string, v ...interface{})
}

type LoggerHandler

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

func DefaultLogger

func DefaultLogger() *LoggerHandler

func NewLogger

func NewLogger(config *Config) *LoggerHandler

func (*LoggerHandler) Close

func (lh *LoggerHandler) Close()

func (*LoggerHandler) Debug

func (lh *LoggerHandler) Debug(text string, v ...interface{})

func (*LoggerHandler) Error

func (lh *LoggerHandler) Error(text string, v ...interface{})

func (*LoggerHandler) Fatal

func (lh *LoggerHandler) Fatal(text string, v ...interface{})

func (*LoggerHandler) Info

func (lh *LoggerHandler) Info(text string, v ...interface{})

func (*LoggerHandler) Trace

func (lh *LoggerHandler) Trace(text string, v ...interface{})

func (*LoggerHandler) Warn

func (lh *LoggerHandler) Warn(text string, v ...interface{})

Jump to

Keyboard shortcuts

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