log

package
v0.0.0-...-976baef Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrUnknownLevel unknown log level
	ErrUnknownLevel = errors.New("unknown log level")
)

Functions

This section is empty.

Types

type Fields

type Fields logrus.Fields

Fields own declaration of logrus Fields

type Level

type Level string

Level type

const (
	// LevelDebug usually only enabled when debugging
	LevelDebug Level = "debug"
	// LevelInfo general operational entries about what's going on inside the application
	LevelInfo Level = "info"
	// LevelWarn non-critical entries that deserve eyes
	LevelWarn Level = "warn"
	// LevelError used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	LevelError Level = "error"
	// LevelFatal Logs and then calls `logger.Exit(1)`
	LevelFatal Level = "fatal"
	// LevelPanic logs and then calls panic
	LevelPanic Level = "panic"
)

func ParseLevel

func ParseLevel(level string) (Level, error)

ParseLevel takes a string level and returns the Level constant

func (*Level) String

func (l *Level) String() string

String return string value of a Level constant

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugln(args ...interface{})
	Debugf(msg string, args ...interface{})
	Infof(msg string, args ...interface{})
	Info(msg string)
	Infoln(...interface{})
	Warn(msg string)
	Warnln(...interface{})
	Warnf(msg string, args ...interface{})
	Error(msg string)
	Errorf(msg string, args ...interface{})
	Fatalf(msg string, args ...interface{})
	Print(args ...interface{})
	Printf(msg string, args ...interface{})
	Println(...interface{})
	Trace(args ...interface{})
	Tracef(msg string, args ...interface{})
	Traceln(...interface{})
	Verbose() bool

	// WithFields should return a logger which is annotated with the given
	// fields. These fields should be added to every logging call on the
	// returned logger.
	WithFields(m map[string]interface{}) Logger
	WithPrefix(prefix string) Logger

	Level() Level
}

Logger implementation is responsible for providing structured and leveled logging functions. Logger implementation is responsible for providing structured and levled logging functions.

func New

func New(wr io.Writer, level Level, file string) Logger

New returns a logger implemented using the logrus package.

type LogrusFileHook

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

LogrusFileHook hook for logrus to write log to file

func NewLogrusFileHook

func NewLogrusFileHook(file string, flag int, chmod os.FileMode) (*LogrusFileHook, error)

NewLogrusFileHook returns new file hook object for logrus

func (*LogrusFileHook) Fire

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

Fire func used by logrus to write the log into a log file

func (*LogrusFileHook) Levels

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

Levels defines in which log levels the file hooks works

Jump to

Keyboard shortcuts

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