phuslu

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger 是基于 phuslu/log 的日志适配器。

phuslu/log 是业界性能最高的结构化日志库之一,采用零内存分配设计, 在高并发场景下吞吐量显著优于 zap 和 zerolog。

Example:

// 使用默认配置(控制台 JSON 输出):
logger := phuslu.NewLogger()

// 使用自定义 phuslu.Logger:
pl := &log.Logger{
    Level:  log.DebugLevel,
    Writer: &log.ConsoleWriter{Writer: os.Stderr},
}
logger := phuslu.NewLoggerWith(pl)
defer logger.Close()

func NewLogger

func NewLogger() *Logger

NewLogger 创建一个带有默认配置的 phuslu 日志记录器。 默认输出到 stderr,JSON 格式,INFO 级别。

func NewLoggerWith

func NewLoggerWith(l *log.Logger) *Logger

NewLoggerWith 使用给定的 phuslu.Logger 创建适配器。

func (*Logger) Close

func (l *Logger) Close() error

Close 刷新并关闭底层 phuslu.Logger。

func (*Logger) Debug

func (l *Logger) Debug(_ context.Context, msg string, keyvals ...any)

Debug 输出 DEBUG 级别日志。

func (*Logger) Enabled

func (l *Logger) Enabled(level bLogger.Level) bool

Enabled 报告给定级别是否会被输出。

func (*Logger) Error

func (l *Logger) Error(_ context.Context, msg string, keyvals ...any)

Error 输出 ERROR 级别日志。

func (*Logger) Info

func (l *Logger) Info(_ context.Context, msg string, keyvals ...any)

Info 输出 INFO 级别日志。

func (*Logger) Warn

func (l *Logger) Warn(_ context.Context, msg string, keyvals ...any)

Warn 输出 WARN 级别日志。

func (*Logger) With

func (l *Logger) With(keyvals ...any) bLogger.Logger

With 返回附加了指定 key-value 对的新 Logger 实例。

Jump to

Keyboard shortcuts

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