log

package
v0.0.0-...-020e20f Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel logrus.Level = iota
	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
)

Variables

View Source
var (
	// PkgDebugLogFilter is the log filter
	// if package name exists and log level is more verbose, the log will be dropped
	PkgDebugLogFilter = map[string]logrus.Level{
		"metric": InfoLevel,
		"rpc":    InfoLevel,
	}
	// SimpleLog is the flag of simple log format
	// "Y" for true, "N" for false. defined in `go build`
	SimpleLog = "N"
)

Functions

func AddHook

func AddHook(hook logrus.Hook)

AddHook adds a hook to the standard logger hooks.

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug on the standard logger.

func Debugf

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

Debugf logs a message at level Debug on the standard logger.

func Debugln

func Debugln(args ...interface{})

Debugln logs a message at level Debug on the standard logger.

func Error

func Error(args ...interface{})

Error logs a message at level Error on the standard logger.

func Errorf

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

Errorf logs a message at level Error on the standard logger.

func Errorln

func Errorln(args ...interface{})

Errorln logs a message at level Error on the standard logger.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal on the standard logger.

func Fatalf

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

Fatalf logs a message at level Fatal on the standard logger.

func Fatalln

func Fatalln(args ...interface{})

Fatalln logs a message at level Fatal on the standard logger.

func GetLevel

func GetLevel() logrus.Level

GetLevel returns the standard logger level.

func Info

func Info(args ...interface{})

Info logs a message at level Info on the standard logger.

func Infof

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

Infof logs a message at level Info on the standard logger.

func Infoln

func Infoln(args ...interface{})

Infoln logs a message at level Info on the standard logger.

func Panic

func Panic(args ...interface{})

Panic logs a message at level Panic on the standard logger.

func Panicf

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

Panicf logs a message at level Panic on the standard logger.

func Panicln

func Panicln(args ...interface{})

Panicln logs a message at level Panic on the standard logger.

func ParseLevel

func ParseLevel(lvl string) (logrus.Level, error)

ParseLevel parse the level string and returns the logger level.

func Print

func Print(args ...interface{})

Print logs a message at level Info on the standard logger.

func Printf

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

Printf logs a message at level Info on the standard logger.

func Println

func Println(args ...interface{})

Println logs a message at level Info on the standard logger.

func SetFormatter

func SetFormatter(formatter logrus.Formatter)

SetFormatter sets the standard logger formatter.

func SetLevel

func SetLevel(level logrus.Level)

SetLevel sets the standard logger level.

func SetOutput

func SetOutput(out io.Writer)

SetOutput sets the standard logger output.

func SetStringLevel

func SetStringLevel(lvl string, defaultLevel logrus.Level)

SetStringLevel enforce current log level.

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn on the standard logger.

func Warnf

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

Warnf logs a message at level Warn on the standard logger.

func Warning

func Warning(args ...interface{})

Warning logs a message at level Warn on the standard logger.

func Warningf

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

Warningf logs a message at level Warn on the standard logger.

func Warningln

func Warningln(args ...interface{})

Warningln logs a message at level Warn on the standard logger.

func Warnln

func Warnln(args ...interface{})

Warnln logs a message at level Warn on the standard logger.

Types

type CallerHook

type CallerHook struct {
	StackLevels []logrus.Level
}

CallerHook defines caller awareness hook for logrus.

func NewCallerHook

func NewCallerHook(stackLevels []logrus.Level) *CallerHook

NewCallerHook creates new CallerHook.

func StandardCallerHook

func StandardCallerHook() *CallerHook

StandardCallerHook is a convenience initializer for LogrusStackHook{} with default args.

func (*CallerHook) Fire

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

Fire defines hook event handler.

func (*CallerHook) Levels

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

Levels define hook applicable level.

type Entry

type Entry logrus.Entry

Entry defines alias for logrus entry.

func NewEntry

func NewEntry(logger *Logger) *Entry

NewEntry returns new entry for logrus logger.

func WithError

func WithError(err error) *Entry

WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.

func WithField

func WithField(key string, value interface{}) *Entry

WithField creates an entry from the standard logger and adds a field to it. If you want multiple fields, use `WithFields`.

Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.

func WithFields

func WithFields(fields Fields) *Entry

WithFields creates an entry from the standard logger and adds multiple fields to it. This is simply a helper for `WithField`, invoking it once for each field.

Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal or Panic on the Entry it returns.

func WithTime

func WithTime(t time.Time) *Entry

WithTime add time fields to log entry.

func (*Entry) Debug

func (entry *Entry) Debug(args ...interface{})

Debug record a new debug level log.

func (*Entry) Debugf

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

Debugf record a debug level log.

func (*Entry) Debugln

func (entry *Entry) Debugln(args ...interface{})

Debugln record a debug level log.

func (*Entry) Error

func (entry *Entry) Error(args ...interface{})

Error record a new error level log.

func (*Entry) Errorf

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

Errorf record a error level log.

func (*Entry) Errorln

func (entry *Entry) Errorln(args ...interface{})

Errorln record a error level log.

func (*Entry) Fatal

func (entry *Entry) Fatal(args ...interface{})

Fatal record a fatal level log.

func (*Entry) Fatalf

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

Fatalf record a fatal level log.

func (*Entry) Fatalln

func (entry *Entry) Fatalln(args ...interface{})

Fatalln record a fatal level log.

func (*Entry) Info

func (entry *Entry) Info(args ...interface{})

Info record a new info level log.

func (*Entry) Infof

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

Infof record a info level log.

func (*Entry) Infoln

func (entry *Entry) Infoln(args ...interface{})

Infoln record a info level log.

func (*Entry) Panic

func (entry *Entry) Panic(args ...interface{})

Panic record a panic level log.

func (*Entry) Panicf

func (entry *Entry) Panicf(format string, args ...interface{})

Panicf record a panic level log.

func (*Entry) Panicln

func (entry *Entry) Panicln(args ...interface{})

Panicln record a panic level log.

func (*Entry) Print

func (entry *Entry) Print(args ...interface{})

Print record a new non-level log.

func (*Entry) Printf

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

Printf record a new non-level log.

func (*Entry) Println

func (entry *Entry) Println(args ...interface{})

Println record a non-level log.

func (*Entry) String

func (entry *Entry) String() (string, error)

Returns the string representation from the reader and ultimately the formatter.

func (*Entry) Warn

func (entry *Entry) Warn(args ...interface{})

Warn record a new warning level log.

func (*Entry) Warnf

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

Warnf record a warning level log.

func (*Entry) Warning

func (entry *Entry) Warning(args ...interface{})

Warning record a new warning level log.

func (*Entry) Warningf

func (entry *Entry) Warningf(format string, args ...interface{})

Warningf record a warning level log.

func (*Entry) Warningln

func (entry *Entry) Warningln(args ...interface{})

Warningln record a warning level log.

func (*Entry) Warnln

func (entry *Entry) Warnln(args ...interface{})

Warnln record a warning level log.

func (*Entry) WithError

func (entry *Entry) WithError(err error) *Entry

WithError adds an error as single field (using the key defined in ErrorKey) to the Entry.

func (*Entry) WithField

func (entry *Entry) WithField(key string, value interface{}) *Entry

WithField add a single field to the Entry.

func (*Entry) WithFields

func (entry *Entry) WithFields(fields Fields) *Entry

WithFields add a map of fields to the Entry.

func (*Entry) WithTime

func (entry *Entry) WithTime(t time.Time) *Entry

WithTime overrides the time of the Entry.

type Fields

type Fields logrus.Fields

Fields defines the field map to pass to `WithFields`.

type Logger

type Logger logrus.Logger

Logger wraps logrus logger type.

func StandardLogger

func StandardLogger() *Logger

StandardLogger returns the standard logger.

func (*Logger) Printf

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

Printf logs a message at level Info on the standard logger.

type NilFormatter

type NilFormatter struct{}

NilFormatter just discards the log entry.

func (*NilFormatter) Format

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

Format just return nil, nil for discarding log entry.

type NilWriter

type NilWriter struct{}

NilWriter just discards the log entry.

func (*NilWriter) Write

func (w *NilWriter) Write(p []byte) (n int, err error)

Write just return 0, nil for discarding log entry.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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