log

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 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 Config

type Config struct {
	Level      string // debug, info, warn, error
	OutputPath string // stdout, stderr, file path
	Format     string // json, console
}

Config 日志配置

type Field

type Field struct {
	Key   string
	Value any
}

Field 日志字段

func Any

func Any(key string, value any) Field

Any 创建任意类型字段

func Bool

func Bool(key string, value bool) Field

Bool 创建布尔字段

func Error

func Error(err error) Field

Error 创建错误字段

func Float64

func Float64(key string, value float64) Field

Float64 创建浮点数字段

func Int

func Int(key string, value int) Field

Int 创建整数字段

func Int64

func Int64(key string, value int64) Field

Int64 创建 int64 字段

func String

func String(key, value string) Field

String 创建字符串字段

type Logger

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

Logger 日志记录器

func New

func New(cfg Config) (*Logger, error)

New 创建新的日志记录器

func NewDefault

func NewDefault() *Logger

NewDefault 创建默认日志记录器

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...Field)

Debug 记录调试信息

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...Field)

Error 记录错误信息

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...Field)

Fatal 记录致命错误并退出

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...Field)

Info 记录一般信息

func (*Logger) Sync

func (l *Logger) Sync() error

Sync 刷新日志缓冲

func (*Logger) Warn

func (l *Logger) Warn(msg string, fields ...Field)

Warn 记录警告信息

func (*Logger) With

func (l *Logger) With(fields ...Field) *Logger

With 添加字段

Jump to

Keyboard shortcuts

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