log

package
v0.0.0-...-a610f59 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Log is the same as the default standard logger from "log".

Functions

This section is empty.

Types

type Level

type Level int

A Level is a logging priority. Higher levels are more important. This is here as a convenience when using the various log options.

const (
	// DebugLevel logs are typically voluminous,
	// and are usually disabled in production.
	DebugLevel Level = iota - 1

	// InfoLevel is the default logging priority.
	InfoLevel

	// WarnLevel logs are more important than Info,
	// but don't need individual human review.
	WarnLevel

	// ErrorLevel logs are high-priority. If an application runs
	// smoothly, it shouldn't generate any error-level logs.
	ErrorLevel

	// PanicLevel logs a message, then panics.
	PanicLevel

	// FatalLevel logs a message, then calls os.Exit(1).
	FatalLevel
)

type Logger

type Logger interface {
	// Debug logs args when the logger level is debug.
	Debug(v ...interface{})

	// Debugf formats args and logs the result when the logger level is debug.
	Debugf(format string, v ...interface{})

	// Info logs args when the logger level is info.
	Info(args ...interface{})

	// Infof formats args and logs the result when the logger level is info.
	Infof(format string, v ...interface{})

	// Warn logs args when the logger level is warn.
	Warn(v ...interface{})

	// Warnf formats args and logs the result when the logger level is warn.
	Warnf(format string, v ...interface{})

	// Error logs args when the logger level is error.
	Error(v ...interface{})

	// Errorf formats args and logs the result when the logger level is debug.
	Errorf(format string, v ...interface{})

	// Panic logs args on panic.
	Panic(v ...interface{})

	// Panicf formats args and logs the result on panic.
	Panicf(format string, v ...interface{})

	// Fatal logs args when the error is fatal.
	Fatal(v ...interface{})

	// Fatalf formats args and logs the result when the error is fatal.
	Fatalf(format string, v ...interface{})
}

Logger is a generic logger interface.

func Named

func Named(logger interface{}, name string) Logger

Named adds a name string to the logger. How the name is added is logger specific i.e. a logrus field or std logger prefix, etc.

func NewLogrusLoggerWithLevel

func NewLogrusLoggerWithLevel(lvl Level) Logger

NewLogrusLoggerWithLevel returns a new production logrus logger with the log level.

func NewStdLogger

func NewStdLogger(lvl Level, out io.Writer, prefix string, flag int) Logger

NewStdLogger returns a new standard logger with the log level.

func NewStdLoggerWithLevel

func NewStdLoggerWithLevel(lvl Level) Logger

NewStdLoggerWithLevel is a stderr logger with the log level.

func NewZapLoggerWithLevel

func NewZapLoggerWithLevel(lvl Level) Logger

NewZapLoggerWithLevel returns a new production zap logger with the log level.

Jump to

Keyboard shortcuts

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