logging

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2026 License: MIT Imports: 9 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogger

func NewLogger(cfg *LogSettings, opts ...LoggerOption) (*logrus.Logger, error)

NewLogger creates and configures a new logrus.Logger based on the provided configuration and options.

Types

type LogSettings

type LogSettings struct {
	LogFile    string  `yaml:"log_file"`
	MaxSize    int     `yaml:"max_size"`
	MaxBackups int     `yaml:"max_backups"`
	MaxAge     int     `yaml:"max_age"`
	LogLevel   *string `yaml:"log_level"`
	LogOutput  *string `yaml:"log_output,omitempty"` // "stdout" or "stderr"
}

type LoggerOption added in v1.4.0

type LoggerOption func(*logrus.Logger)

LoggerOption defines a functional option for configuring a logger.

func WithOutput added in v1.4.0

func WithOutput(w io.Writer) LoggerOption

WithOutput sets the output destination for the logger.

type SourceFormatter

type SourceFormatter struct {
	// Underlying is the formatter (e.g., &logrus.TextFormatter{}) that we will delegate to.
	Underlying logrus.Formatter
	// AddSpace indicates whether to add an extra newline for readability, typically for text format.
	AddSpace bool
}

SourceFormatter is a custom formatter to control the caller output. It wraps a standard formatter (like TextFormatter or JSONFormatter).

func (*SourceFormatter) Format

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

Format renders a single log entry.

Jump to

Keyboard shortcuts

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