logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CtxKeyLogID = "U_LOGID"
)

Variables

This section is empty.

Functions

func Debug

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

func DebugX

func DebugX(field string, format string, args ...interface{})

func Error

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

func ErrorX

func ErrorX(field string, format string, args ...interface{})

func Fatal

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

func FatalX

func FatalX(field string, format string, args ...interface{})

func FlushLog

func FlushLog()

FlushLog flushes any buffered log entries

func GetLogID

func GetLogID(ctx context.Context) string

func Info

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

func InfoX

func InfoX(field string, format string, args ...interface{})

func InitLog

func InitLog(output string) (err error)

func InitLogWithConfig added in v0.2.0

func InitLogWithConfig(output string, cfg RotateConfig) (err error)

InitLogWithConfig initializes the logger with custom rotation config.

func Warn

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

func WarnX

func WarnX(field string, format string, args ...interface{})

Types

type ConsoleHook

type ConsoleHook struct {
	Writer    io.Writer
	Formatter logrus.Formatter
}

func (*ConsoleHook) Fire

func (hook *ConsoleHook) Fire(entry *logrus.Entry) error

func (*ConsoleHook) Levels

func (hook *ConsoleHook) Levels() []logrus.Level

type FileHook

type FileHook struct {
	Writer    io.Writer
	Formatter logrus.Formatter
}

func (*FileHook) Fire

func (hook *FileHook) Fire(entry *logrus.Entry) error

func (*FileHook) Levels

func (hook *FileHook) Levels() []logrus.Level

type Logger

type Logger struct {
	*logrus.Logger
}

func NewLogger

func NewLogger(filename string) (*Logger, error)

func NewLoggerWithConfig added in v0.2.0

func NewLoggerWithConfig(filename string, rotateCfg RotateConfig) (*Logger, error)

NewLoggerWithConfig creates a logger with custom rotation config.

func (*Logger) FlushLog

func (l *Logger) FlushLog()

FlushLog flushes any buffered log entries

func (*Logger) GetLogID

func (l *Logger) GetLogID(ctx context.Context) string

type RotateConfig added in v0.2.0

type RotateConfig struct {
	MaxSize    int64 // Max size in bytes before rotation.
	MaxBackups int   // Max number of old log files to keep
	MaxAge     int   // Max days to keep old log files
}

RotateConfig holds configuration for log rotation.

type RotateHook

type RotateHook struct {
	Filename   string
	MaxSize    int64
	MaxBackups int
	MaxAge     int
	LocalTime  bool
	// contains filtered or unexported fields
}

func NewRotateHook

func NewRotateHook(filename string) *RotateHook

func NewRotateHookWithConfig added in v0.2.0

func NewRotateHookWithConfig(filename string, cfg RotateConfig) *RotateHook

NewRotateHookWithConfig creates a RotateHook with custom configuration. maxSize is in MB, will be converted to bytes internally.

func (*RotateHook) Fire

func (hook *RotateHook) Fire(entry *logrus.Entry) error

func (*RotateHook) Levels

func (hook *RotateHook) Levels() []logrus.Level

Jump to

Keyboard shortcuts

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