alog

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

from gozero logx.rotatelogger.go

Index

Constants

View Source
const (
	LOGDEBUG int = iota
	LOGINFO
	LOGERROR
	LOGSEVERE
)

log level const definition

View Source
const (
	LogBufsize = 4096
)

Variables

View Source
var (
	Level = map[string]int{
		"debug":  LOGDEBUG,
		"info":   LOGINFO,
		"error":  LOGERROR,
		"severe": LOGSEVERE,
	}

	LogDebug  func(*LogCtx, string, ...interface{})
	LogInfo   func(*LogCtx, string, ...interface{})
	LogError  func(*LogCtx, string, ...interface{})
	LogSevere func(*LogCtx, string, ...interface{})
)

Functions

func CloseLogFiles

func CloseLogFiles()

关闭所有 LogFile

func ReopenLogFiles

func ReopenLogFiles()

重新打开所有 LogFile

Types

type DailyRotateRule

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

func (*DailyRotateRule) BackupFileName

func (r *DailyRotateRule) BackupFileName() string

func (*DailyRotateRule) MarkRotated

func (r *DailyRotateRule) MarkRotated()

func (*DailyRotateRule) OutdatedFiles

func (r *DailyRotateRule) OutdatedFiles() []string

func (*DailyRotateRule) ShallRotate

func (r *DailyRotateRule) ShallRotate(_ int64) bool

type LogConf

type LogConf struct {
	LogLevel   string `json:",default=info,options=[debug,info,error,severe]"`
	LogFile    string `json:",default=logs/websocket.log"`
	StackLayer uint8  `json:",default=1"`
	KeepDays   int32  `json:",default=7"`
	Rotation   string `json:",default=daily,options=[daily]"`
}

type LogCtx

type LogCtx struct {
	// Log Prefix
	Prefix func() string

	// Log Suffix
	Suffix func() string

	// Log Level
	LogLevel int
}

LogCtx for user defined prefix and suffix add in log

type LogFile

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

func CreateLogFile

func CreateLogFile(conf *LogConf) *LogFile

创建 LogFile

func (*LogFile) Close

func (lf *LogFile) Close()

停止 LogFile

func (*LogFile) Flush

func (lf *LogFile) Flush()

将 LogFile 中的内容刷入文件

func (*LogFile) Reopen

func (lf *LogFile) Reopen()

重新打开 LogFile,用于日志 rotate 使用

func (*LogFile) Write

func (lf *LogFile) Write(b []byte)

向 LogFile 中写入内容

type Logger

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

func NewWsLog

func NewWsLog(conf *LogConf) *Logger

创建新的 Log

func (*Logger) LogDebug

func (l *Logger) LogDebug(c *LogCtx, format string, args ...interface{})

写入 Debug 日志

func (*Logger) LogError

func (l *Logger) LogError(c *LogCtx, format string, args ...interface{})

写入 Error 日志

func (*Logger) LogInfo

func (l *Logger) LogInfo(c *LogCtx, format string, args ...interface{})

写入 Info 日志

func (*Logger) LogSevere

func (l *Logger) LogSevere(c *LogCtx, format string, args ...interface{})

写入 Fatal 日志

func (*Logger) Printf

func (l *Logger) Printf(format string, args ...interface{})

type RotateRule

type RotateRule interface {
	BackupFileName() string
	MarkRotated()
	OutdatedFiles() []string
	ShallRotate(size int64) bool
}

func CreateDailyRotateRule

func CreateDailyRotateRule(filename string, days int) RotateRule

Jump to

Keyboard shortcuts

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