log

package
v0.0.0-...-5b9d864 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DebugLevel = zapcore.DebugLevel
	InfoLevel  = zapcore.InfoLevel
	WarnLevel  = zapcore.WarnLevel
	ErrorLevel = zapcore.ErrorLevel
	PanicLevel = zapcore.PanicLevel
	FatalLevel = zapcore.FatalLevel
)

日志级别常量

Variables

This section is empty.

Functions

func Any

func Any(key string, val interface{}) zap.Field

Any 创建任意类型字段

func Bool

func Bool(key string, val bool) zap.Field

Bool 创建布尔字段

func Debug

func Debug(msg string, fields ...zap.Field)

Debug 输出Debug级别日志

func Debugf

func Debugf(format string, args ...interface{})

Debugf 格式化输出Debug级别日志

func Err

func Err(err error) zap.Field

Err 创建错误字段

func Error

func Error(msg string, fields ...zap.Field)

Error 输出Error级别日志

func Errorf

func Errorf(format string, args ...interface{})

Errorf 格式化输出Error级别日志

func Fatal

func Fatal(msg string, fields ...zap.Field)

Fatal 输出Fatal级别日志

func Fatalf

func Fatalf(format string, args ...interface{})

Fatalf 格式化输出Fatal级别日志

func Float64

func Float64(key string, val float64) zap.Field

Float64 创建浮点数字段

func Info

func Info(msg string, fields ...zap.Field)

Info 输出Info级别日志

func Infof

func Infof(format string, args ...interface{})

Infof 格式化输出Info级别日志

func Init

func Init(opts *Options)

Init 初始化全局日志

func Int

func Int(key string, val int) zap.Field

Int 创建整数字段

func Int64

func Int64(key string, val int64) zap.Field

Int64 创建64位整数字段

func String

func String(key, val string) zap.Field

String 创建字符串字段

func Sync

func Sync() error

Sync 同步日志

func Warn

func Warn(msg string, fields ...zap.Field)

Warn 输出Warn级别日志

func Warnf

func Warnf(format string, args ...interface{})

Warnf 格式化输出Warn级别日志

Types

type Level

type Level = zapcore.Level

Level 日志级别类型

type Logger

type Logger interface {
	Debug(msg string, fields ...zap.Field)
	Info(msg string, fields ...zap.Field)
	Warn(msg string, fields ...zap.Field)
	Error(msg string, fields ...zap.Field)
	Fatal(msg string, fields ...zap.Field)
	With(fields ...zap.Field) Logger
	Sugar() *zap.SugaredLogger
	Sync() error
}

Logger 日志接口

func With

func With(fields ...zap.Field) Logger

With 创建带有字段的子日志

type Options

type Options struct {
	Level       string   `json:"level" mapstructure:"level"`
	Format      string   `json:"format" mapstructure:"format"`
	OutputPaths []string `json:"output-paths" mapstructure:"output-paths"`
	Development bool     `json:"development" mapstructure:"development"`
	EnableColor bool     `json:"enable-color" mapstructure:"enable-color"`
}

Options 日志配置选项

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions 默认日志配置

Jump to

Keyboard shortcuts

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