logger

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateProductZapLogger

func CreateProductZapLogger(op ...Option) (*zap.Logger, error)

CreateProductZapLogger 创建一个生产级别的 zap 日志记录器。

func NewZapWriter

func NewZapWriter(logger *zap.Logger, level zapcore.Level) io.Writer

NewZapWriter 创建一个新的 io.Writer,输出到 zap.Logger level: 日志级别 (zap.InfoLevel, zap.WarnLevel 等)

Types

type LogConfig

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

type Option

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

An Option configures a Logger.

func SetConsoleWriterSyncer

func SetConsoleWriterSyncer(consoleWriter bool) Option

func SetLogCompress

func SetLogCompress(compress bool) Option

SetLogCompress 设置是否压缩日志文件

func SetLogFilename

func SetLogFilename(filename string) Option

SetLogFilename 设置日志文件名

func SetLogLevel

func SetLogLevel(level zapcore.Level) Option

SetLogLevel 设置日志级别

func SetLogLevelKey

func SetLogLevelKey(levelKey string) Option

SetLogLevelKey 设置日志级别字段名

func SetLogMaxAge

func SetLogMaxAge(maxAge int) Option

SetLogMaxAge 设置日志文件最大保存天数

func SetLogMaxBackups

func SetLogMaxBackups(maxBackups int) Option

SetLogMaxBackups 设置日志文件最大备份数

func SetLogMaxSize

func SetLogMaxSize(maxSize int) Option

SetLogMaxSize 设置日志文件最大大小(MB)

type ZapWriter

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

ZapWriter 将 io.Writer 接口桥接到 zap.Logger

func (*ZapWriter) Flush

func (w *ZapWriter) Flush()

Flush 将剩余缓冲区内容输出(例如程序退出时调用)

func (*ZapWriter) Write

func (w *ZapWriter) Write(p []byte) (n int, err error)

Write 实现 io.Writer 接口

Jump to

Keyboard shortcuts

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