logging

package
v0.23.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Default

func Default() *logrus.Logger

Default returns pre-configured logger.

func DefaultWithPrefix

func DefaultWithPrefix(prefix string) *logrus.Entry

DefaultWithPrefix returns a default instance of logger with prefix.

func New

func New(cfg Config) (*logrus.Logger, error)

New returns logger with config.

func WithPrefix

func WithPrefix(lg *logrus.Logger, prefix string) *logrus.Entry

Types

type Config

type Config struct {
	FileOut string `split_words:"true"`
	FileErr string `split_words:"true"`
}

Config represents logger settings.

type Hook

type Hook struct {
	Writer    io.Writer
	LogLevels []log.Level
}

Hook is a hook that writes logs of specified LogLevels to specified Writer

func (*Hook) Fire

func (hook *Hook) Fire(entry *log.Entry) error

Fire will be called when some logging function is called with current hook It will format log entry to string and write it to appropriate writer

func (*Hook) Levels

func (hook *Hook) Levels() []log.Level

Levels define on which log levels this hook would trigger

type Logger

type Logger interface {
	// Standard Lib logger methods.
	Print(v ...interface{})
	Println(v ...interface{})
	Printf(format string, v ...interface{})

	Panic(v ...interface{})
	Panicln(v ...interface{})
	Panicf(format string, v ...interface{})

	Fatal(v ...interface{})
	Fatalln(v ...interface{})
	Fatalf(format string, v ...interface{})

	// Custom logger methods.
	Info(v ...interface{})
	Infoln(v ...interface{})
	Infof(format string, v ...interface{})

	Error(v ...interface{})
	Errorln(v ...interface{})
	Errorf(format string, v ...interface{})

	Debug(v ...interface{})
	Debugln(v ...interface{})
	Debugf(format string, v ...interface{})

	Warn(v ...interface{})
	Warnln(v ...interface{})
	Warnf(format string, v ...interface{})
}

Logger provides access to logging service.

Jump to

Keyboard shortcuts

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