logging

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HaveDebugTag

func HaveDebugTag(tag string) bool

func SetupVerboseLog

func SetupVerboseLog(log Log, isVerbose bool)

Types

type DebugFunc

type DebugFunc func(format string, args ...interface{})

func Debug

func Debug(tag string) DebugFunc

type DevCtlFormatter

type DevCtlFormatter struct{}

func (DevCtlFormatter) Format

func (c DevCtlFormatter) Format(entry *logrus.Entry) (bytes []byte, err error)

type Log

type Log interface {
	logrus.FieldLogger
	Fatalf(format string, args ...interface{})
	Panicf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Logf(level LogLevel, format string, args ...interface{})

	Child(name string) Log
	SetLevel(level LogLevel)
}

func NewLogger

func NewLogger(opts ...Option) Log

type LogLevel

type LogLevel int
const (
	// Debug messages, write to debug logs only by logutils.Debug.
	LogLevelDebug LogLevel = 0

	// Information messages, don't write too much messages,
	// only useful ones: they are shown when running with -v.
	LogLevelInfo LogLevel = 1

	// Hidden errors: non critical errors: work can be continued, no need to fail whole program;
	// tests will crash if any warning occurred.
	LogLevelWarn LogLevel = 2

	// Only not hidden from user errors: whole program failing, usually
	// error logging happens in 1-2 places: in the "main" function.
	LogLevelError LogLevel = 3
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger struct {
	Output    *bytes.Buffer
	IsVerbose bool
	OutWriter io.Writer
	DebugFunc DebugFunc
	// contains filtered or unexported fields
}

func (*Logger) Child

func (l *Logger) Child(name string) Log

func (*Logger) Debug

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

func (*Logger) Debugf

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

func (*Logger) Debugln

func (l *Logger) Debugln(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

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) Fatalln

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

func (*Logger) Info

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

func (*Logger) Infof

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

func (*Logger) Infoln

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

func (*Logger) Logf

func (l *Logger) Logf(lvl LogLevel, format string, args ...interface{})

func (*Logger) Panic

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

func (*Logger) Panicf

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

func (*Logger) Panicln

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

func (*Logger) Print

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

func (*Logger) Printf

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

func (*Logger) Println

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

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

func (*Logger) Warn

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

func (*Logger) Warnf

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

func (*Logger) Warning

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

func (*Logger) Warningf

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

func (*Logger) Warningln

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

func (*Logger) Warnln

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

func (*Logger) WithError

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

func (*Logger) WithField

func (l *Logger) WithField(key string, value interface{}) *logrus.Entry

func (*Logger) WithFields

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

type Option

type Option func(*Logger) *Logger

func WithBuffer

func WithBuffer(b *bytes.Buffer) Option

func WithDebugFunc

func WithDebugFunc(debugFn DebugFunc) Option

func WithExitFn

func WithExitFn(exitFn func(int)) Option

func WithFormatter

func WithFormatter(format logrus.Formatter) Option

func WithLevel

func WithLevel(level LogLevel) Option

func WithName

func WithName(name string) Option

func WithOutputs

func WithOutputs(w ...io.Writer) Option

func WithVerbose

func WithVerbose(verbose bool) Option

Jump to

Keyboard shortcuts

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