log

package module
v0.0.0-...-1cb19c4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: MIT Imports: 12 Imported by: 4

README

go-log

An fmt-style wrapper to github.com/sirupsen/logrus

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 Level = Level(logrus.PanicLevel)
	// FatalLevel level. Logs and then calls `os.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel = Level(logrus.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 = Level(logrus.ErrorLevel)
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = Level(logrus.WarnLevel)
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel = Level(logrus.InfoLevel)
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = Level(logrus.DebugLevel)
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel = Level(logrus.TraceLevel)
)

These are the different logging levels.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug logs a message at level Debug.

func Debugf

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

Debugf logs a message at level Debug.

func Debugln

func Debugln(args ...interface{})

Debugln logs a message at level Debug.

func Error

func Error(args ...interface{})

Error logs a message at level Error.

func Errorf

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

Errorf logs a message at level Error.

func Errorln

func Errorln(args ...interface{})

Errorln logs a message at level Error.

func Fatal

func Fatal(args ...interface{})

Fatal logs a message at level Fatal.log.

func Fatalf

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

Fatalf logs a message at level Fatal.log.

func Fatalln

func Fatalln(args ...interface{})

Fatalln logs a message at level atal.log.

func Info

func Info(args ...interface{})

Info logs a message at level Info.

func Infof

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

Infof logs a message at level Info.

func Infoln

func Infoln(args ...interface{})

Infoln logs a message at level Info.

func Init

func Init(opts ...Option)

Init initializes the logger.

func Panic

func Panic(args ...interface{})

Panic logs a message at level Panic.

func Panicf

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

Panicf logs a message at level Panic.

func Panicln

func Panicln(args ...interface{})

Panicln logs a message at level Panic.

func Trace

func Trace(args ...interface{})

Trace logs a message at level Trace.

func Tracef

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

Tracef logs a message at level Trace.

func Traceln

func Traceln(args ...interface{})

Traceln logs a message at level Trace.

func Warn

func Warn(args ...interface{})

Warn logs a message at level Warn.

func Warnf

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

Warnf logs a message at level Warn.

func Warnln

func Warnln(args ...interface{})

Warnln logs a message at level Warn.

Types

type Fields

type Fields map[string]interface{}

Fields type, used to pass to `WithFields`.

type Level

type Level logrus.Level

Level type.

type Logger

type Logger interface {
	Trace(args ...interface{})
	Tracef(format string, args ...interface{})
	Traceln(args ...interface{})

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

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

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

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

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

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

	WithError(err error) Logger
	WithField(key string, value interface{}) Logger
	WithFields(fields Fields) Logger
}

Logger defines a logger

func WithError

func WithError(err error) Logger

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{}) Logger

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

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.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option configures the logger.

func WithLevel

func WithLevel(level Level) Option

WithLevel sets the logger level.

func WithOutput

func WithOutput(writer io.Writer) Option

WithOutput sets the logger output

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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