log

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MPL-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v0.8.0

func Debug(args ...interface{})

func Debugf added in v0.8.0

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

func Error added in v0.8.0

func Error(args ...interface{})

func Errorf added in v0.8.0

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

func Errorln added in v0.8.0

func Errorln(args ...interface{})

func Fatal added in v0.8.0

func Fatal(args ...interface{})

func Fatalf added in v0.8.0

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

func Info added in v0.8.0

func Info(args ...interface{})

func Infof added in v0.8.0

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

func NewContext added in v0.8.0

func NewContext(ctx context.Context, lo StdLogger, fields Fields) context.Context

NewContext creates a new log entry and adds it to the given context

func Printf added in v0.8.0

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

func Println added in v0.8.0

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

func Warn added in v0.8.0

func Warn(args ...interface{})

func Warnf added in v0.8.0

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

func WithError added in v0.8.0

func WithError(err error) *logrus.Entry

func WithFields added in v0.8.0

func WithFields(f Fields) *logrus.Entry

func WithLogger added in v0.8.0

func WithLogger() *logrus.Logger

Types

type Fields added in v0.8.0

type Fields = logrus.Fields

type Key added in v0.8.0

type Key string
const LoggerContextKey Key = "log_entry"

type Level

type Level int32

Level represents a log level.

const (
	// FatalLevel is used for undesired and unexpected events that
	// the program cannot recover from.
	FatalLevel Level = iota

	// ErrorLevel is used for undesired and unexpected events that
	// the program can recover from.
	ErrorLevel

	// WarnLevel is used for undesired but relatively expected events,
	// which may indicate a problem.
	WarnLevel

	// InfoLevel is used for general informational log messages.
	InfoLevel

	// DebugLevel is the lowest level of logging.
	// Debug logs are intended for debugging and development purposes.
	DebugLevel
)

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns the Logrus log level constant.

func (Level) String

func (l Level) String() string

String is part of the fmt.Stringer interface.

Used for testing and debugging purposes.

func (Level) ToLogrusLevel

func (l Level) ToLogrusLevel() (logrus.Level, error)

type Logger

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

Logger logs message to io.Writer at various log levels.

func NewLogger

func NewLogger(out io.Writer) *Logger

NewLogger creates and returns a new instance of Logger. Log level is set to DebugLevel by default.

func (*Logger) Debug

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

func (*Logger) Debugf

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

func (*Logger) Error

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

func (*Logger) Errorf

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

func (*Logger) Errorln added in v0.8.0

func (l *Logger) Errorln(args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(args ...interface{})

func (*Logger) Fatalf

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

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) Printf added in v0.8.0

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

func (*Logger) Println added in v0.8.0

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

func (*Logger) SetLevel

func (l *Logger) SetLevel(v Level)

SetLevel sets the logger level. It panics if v is less than DebugLevel or greater than FatalLevel.

func (*Logger) SetPrefix

func (l *Logger) SetPrefix(value interface{})

WithField sets logger fields

func (*Logger) Warn

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

func (*Logger) Warnf

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

func (*Logger) WithError

func (l *Logger) WithError(err error) *logrus.Entry

func (*Logger) WithFields added in v0.8.0

func (l *Logger) WithFields(f Fields) *logrus.Entry

func (*Logger) WithLogger

func (l *Logger) WithLogger() *logrus.Logger

type StdLogger

type StdLogger interface {
	Info(args ...interface{})
	Debug(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Fatal(args ...interface{})

	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})

	WithFields(f Fields) *logrus.Entry
	WithError(err error) *logrus.Entry
}

func FromContext added in v0.8.0

func FromContext(ctx context.Context) StdLogger

FromContext extracts the log entry from the given context

Jump to

Keyboard shortcuts

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