log

package module
v0.0.0-...-97edf12 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields logrus.Fields

Fields 是 logrus.Fields 的别名

type LogLevel

type LogLevel int

LogLevel 是自定义日志级别类型

const (
	// DebugLevel 表示 debug 日志级别
	DebugLevel LogLevel = iota
	// InfoLevel 表示 info 日志级别
	InfoLevel
	// WarnLevel 表示 warn 日志级别
	WarnLevel
	// ErrorLevel 表示 error 日志级别
	ErrorLevel
	// FatalLevel 表示 fatal 日志级别
	FatalLevel
)

type Logger

type Logger interface {
	Debug(args ...interface{})                  // 记录调试级别的日志
	Info(args ...interface{})                   // 记录信息级别的日志
	Warn(args ...interface{})                   // 记录警告级别的日志
	Error(args ...interface{})                  // 记录错误级别的日志
	ErrorWithDetails(message string, err error) // 记录带有额外字段的错误日志,自动添加 error 和 trace 字段
	Fatal(args ...interface{})                  // 记录致命错误级别的日志
	FatalWithDetails(message string, err error) // 记录带有额外字段的致命错误日志,自动添加 error 和 trace 字段
	WithFields(fields Fields) Logger            // 创建带有额外字段的新日志实例
	SetDefaultFields(fields Fields)             // 设置默认字段
}

Logger 是自定义日志接口

func DefaultLogger

func DefaultLogger() Logger

DefaultLogger 返回默认的日志实例

func NewLogger

func NewLogger(options ...Option) Logger

NewLogger 创建自定义日志实例

type Option

type Option func(*loggerImpl)

Option 是用于设置 Logger 的选项函数类型

func WithLevel

func WithLevel(level LogLevel) Option

WithLevel 设置日志级别的选项函数

func WithPath

func WithPath(path string) Option

WithPath 设置日志路径的选项函数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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