log

package
v1.1.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Panic = iota
	Fatal
	Error
	Warn
	Info
	Debug
)

Log levels

Variables

This section is empty.

Functions

func Configure

func Configure(logType string, logLevel string, production bool)

Configure initializes default logger

func Debugf

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

Debugf logs a message with given format and arguments

func E

func E(err error) bool

E logs the error if it's not nil Return true if error is not nil

func EL

func EL(l Logger, err error) bool

EL logs the error if it's not nil with given logger Return true if error is not nil FIXME: this prints file/line of the l.Errorf call not EL caller

func Errorf

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

Errorf logs a message with given format and arguments

func F

func F(err error)

F logs the error if it's not nil and terminate the process

func Fatalf

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

Fatalf logs a message with given format and arguments and then finishes the process with error exit code

func GenWorkerID

func GenWorkerID() string

GenWorkerID generates random 32bit worker ID to be used by loggers

func Infof

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

Infof logs a message with given format and arguments

func Panicf

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

Panicf logs a message with given format and arguments and then panics

func ParseLevel

func ParseLevel(s string) int

ParseLevel converts string level to integer const

func Warnf

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

Warnf logs a message with given format and arguments

Types

type Fields

type Fields map[string]interface{}

Fields is a map of key/value pairs which can be attached to a logger This fields will be printed with every message of the logger

type Logger

type Logger interface {
	// Log at debug level with fmt.Printf-like formatting
	Debugf(format string, args ...interface{})
	// Log at info level with fmt.Printf-like formatting
	Infof(format string, args ...interface{})

	// Log at warning level with fmt.Printf-like formatting
	Warnf(format string, args ...interface{})

	// Log at error level with fmt.Printf-like formatting
	Errorf(format string, args ...interface{})

	// Log at fatal level with fmt.Printf-like formatting, then terminate process (irrecoverable)
	Fatalf(format string, args ...interface{})

	// Log at panic level with fmt.Printf-like formatting, then panic (recoverable)
	Panicf(format string, args ...interface{})

	// Return a logger with the specified key-value pairs set, to be  included in a subsequent normal logging call
	WithFields(keyValues Fields) Logger
}

Logger is our contract for the logger

func WithFields

func WithFields(keyValues Fields) Logger

WithFields attaches given key/value fields and return new logger with those fields attached

type LoggerConstructor

type LoggerConstructor func(level int, production bool) (Logger, error)

LoggerConstructor initializes logger plugin

Jump to

Keyboard shortcuts

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