logging

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logging @Author Clover @Data 2024/7/18 上午10:24:00 @Desc 日志输出

Index

Constants

This section is empty.

Variables

View Source
var Logger = NewLogBuffer()

Logger 定义一个全局的 LogBuffer

Functions

func Close

func Close()

Close 关闭日志文件

func Debug

func Debug(msg string, fields map[string]interface{})

func Error

func Error(msg string, fields ...map[string]interface{})

func ErrorWithErr

func ErrorWithErr(err error, msg string, fields ...map[string]interface{})

func Fatal

func Fatal(msg string, exitCode int, fields ...map[string]interface{})

func Info

func Info(msg string, fields ...map[string]interface{})

Info 定义简化的日志函数

func MonitorLogSize

func MonitorLogSize(maxLogsize int64)

MonitorLogSize checks the log file size and truncates it if it eceeds the max size.

func Warn

func Warn(msg string, fields ...map[string]interface{})

func WarnWithErr

func WarnWithErr(err error, msg string, fields ...map[string]interface{})

Types

type LogBuffer

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

LogBuffer 用于存储日志的缓冲区

func NewLogBuffer

func NewLogBuffer() *LogBuffer

NewLogBuffer 创建一个新的日志缓冲区

func (*LogBuffer) AddEntry

func (lb *LogBuffer) AddEntry(entry LogEntry)

AddEntry 向缓冲区中添加一个日志条目

func (*LogBuffer) Flush

func (lb *LogBuffer) Flush(minLevel zerolog.Level)

Flush 清空缓冲区,并根据日志等级输出日志

func (*LogBuffer) SetActive

func (lb *LogBuffer) SetActive(active bool)

SetActive 设置缓冲区的激活状态

type LogEntry

type LogEntry struct {
	Level   zerolog.Level
	Message string
	Fields  map[string]interface{}
}

LogEntry 定义一个结构体来存储日志消息

Jump to

Keyboard shortcuts

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