logger

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveLogLevel

func ActiveLogLevel() logrus.Level

ActiveLogLevel 返回当前全局 logger 的日志级别。

func Debug

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

func Error

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

func Info

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

func InitLogger

func InitLogger(logDir string, maxFiles int, logLevel int, noFileLog ...bool)

func IsDebugEnabled

func IsDebugEnabled(sink Sink) bool

IsDebugEnabled 允许热路径在构造日志参数前检查级别。自定义 Sink 未声明 级别接口时仍接收 Debug 调用,保持原有日志接入行为。

func Success

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

func WithContext

func WithContext(ctx context.Context, sink Sink) context.Context

Types

type CustomFormatter

type CustomFormatter struct {
	IsColored bool
}

func (*CustomFormatter) Format

func (f *CustomFormatter) Format(entry *logrus.Entry) ([]byte, error)

type Logger

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

func NewLogger

func NewLogger(logDir string, maxFiles int, logLevel int, noFileLog ...bool) *Logger

func (*Logger) Debug

func (l *Logger) Debug(format string, args ...interface{})

func (*Logger) DebugEnabled

func (l *Logger) DebugEnabled() bool

func (*Logger) Error

func (l *Logger) Error(format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(format string, args ...interface{})

func (*Logger) Success

func (l *Logger) Success(format string, args ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(format string, args ...interface{})

type PlainFormatter

type PlainFormatter struct {
	CustomFormatter
}

func (*PlainFormatter) Format

func (f *PlainFormatter) Format(entry *logrus.Entry) ([]byte, error)

type Sink

type Sink interface {
	Debug(string, ...interface{})
	Info(string, ...interface{})
	Warn(string, ...interface{})
	Error(string, ...interface{})
}

Sink 使扫描实例的日志目的地与 CLI 的全局日志配置相互独立。

func Current

func Current() Sink

func Discard

func Discard() Sink

func FromContext

func FromContext(ctx context.Context) Sink

func FromSlog

func FromSlog(l *slog.Logger) Sink

Jump to

Keyboard shortcuts

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