log

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 8 Imported by: 0

README

log

A log package with very simple API that wraps Go's standard "log" to add levelled and logfmt (ish) style logging.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(a ...interface{})

func DebugFields

func DebugFields(fields ...kv.Field)

func Debugf

func Debugf(s string, a ...interface{})

func Error

func Error(a ...interface{})

func ErrorFields

func ErrorFields(fields ...kv.Field)

func Errorf

func Errorf(s string, a ...interface{})

func Fatal

func Fatal(a ...interface{})

func FatalFields

func FatalFields(fields ...kv.Field)

func Fatalf

func Fatalf(s string, a ...interface{})

func IncludeCaller

func IncludeCaller() bool

func Info

func Info(a ...interface{})

func InfoFields

func InfoFields(fields ...kv.Field)

func Infof

func Infof(s string, a ...interface{})

func Log

func Log(calldepth int, lvl LEVEL, a ...interface{})

func LogFields

func LogFields(calldepth int, lvl LEVEL, fields ...kv.Field)

func Logf

func Logf(calldepth int, lvl LEVEL, s string, a ...interface{})

func Panic

func Panic(a ...interface{})

func PanicFields

func PanicFields(fields ...kv.Field)

func Panicf

func Panicf(s string, a ...interface{})

func Print

func Print(a ...interface{})

func PrintFields

func PrintFields(fields ...kv.Field)

func Printf

func Printf(s string, a ...interface{})

func SetIncludeCaller

func SetIncludeCaller(verbose bool)

func SetLevel

func SetLevel(lvl LEVEL)

func SetOutput

func SetOutput(out io.Writer)

func Warn

func Warn(a ...interface{})

func WarnFields

func WarnFields(fields ...kv.Field)

func Warnf

func Warnf(s string, a ...interface{})

Types

type LEVEL

type LEVEL uint8

LEVEL represents a logging level (e.g. info, warn, ...).

const (
	// Available log levels.
	NONE  LEVEL = 0
	PANIC LEVEL = 1
	FATAL LEVEL = 50
	ERROR LEVEL = 100
	WARN  LEVEL = 150
	INFO  LEVEL = 200
	DEBUG LEVEL = 250
	ALL   LEVEL = ^LEVEL(0)
)

func Level

func Level() LEVEL

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger wraps the stdlib log.Logger to provided levelled logging.

func Default

func Default() *Logger

Default returns the default Logger instance.

func New

func New(w io.Writer, min uint8) *Logger

New returns a new instance of Logger writing to given output. A minimum call depth may be specified to skip caller frames in caller info.

func NewFrom

func NewFrom(log *log.Logger, min uint8) *Logger

NewFrom returns a new instance of Logger wrapping the provided standard library logger. A minimum call depth may be specified to skip caller frames in caller info.

func (*Logger) Debug

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

func (*Logger) DebugFields

func (l *Logger) DebugFields(fields ...kv.Field)

func (*Logger) Debugf

func (l *Logger) Debugf(s string, a ...interface{})

func (*Logger) Error

func (l *Logger) Error(a ...interface{})

func (*Logger) ErrorFields

func (l *Logger) ErrorFields(fields ...kv.Field)

func (*Logger) Errorf

func (l *Logger) Errorf(s string, a ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(a ...interface{})

func (*Logger) FatalFields

func (l *Logger) FatalFields(fields ...kv.Field)

func (*Logger) Fatalf

func (l *Logger) Fatalf(s string, a ...interface{})

func (*Logger) IncludeCaller

func (l *Logger) IncludeCaller() bool

IncludeCaller returns whether 'IncludeCaller' is enabled.

func (*Logger) Info

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

func (*Logger) InfoFields

func (l *Logger) InfoFields(fields ...kv.Field)

func (*Logger) Infof

func (l *Logger) Infof(s string, a ...interface{})

func (*Logger) Level

func (l *Logger) Level() LEVEL

Level returns the minimum logging level for the logger.

func (*Logger) Log

func (l *Logger) Log(calldepth int, lvl LEVEL, a ...interface{})

Log calls underlying stdlib log.Logger.Output() to print to the logger with level. Arguments are handled in the manner of fmt.Print.

func (*Logger) LogFields

func (l *Logger) LogFields(calldepth int, lvl LEVEL, fields ...kv.Field)

Logf calls underlying stdlib log.Logger.Output() to print to the logger with level. Arguments formatted using fv.Fields{}.String().

func (*Logger) Logf

func (l *Logger) Logf(calldepth int, lvl LEVEL, s string, a ...interface{})

Logf calls underlying stdlib log.Logger.Output() to print to the logger with level. Arguments are handled in the manner of fmt.Printf.

func (*Logger) Logger

func (l *Logger) Logger() *log.Logger

Logger returns the underlying stdlib log.Logger.

func (*Logger) Panic

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

func (*Logger) PanicFields

func (l *Logger) PanicFields(fields ...kv.Field)

func (*Logger) Panicf

func (l *Logger) Panicf(s string, a ...interface{})

func (*Logger) Print

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

Print calls underlying stdlib log.Logger.Output() to print to the logger. Arguments are handled in the manner of fmt.Print.

func (*Logger) PrintFields

func (l *Logger) PrintFields(fields ...kv.Field)

PrintFields calls underlying stdlib log.Logger.Output() to print to the logger. Arguments formatted using fv.Fields{}.String().

func (*Logger) Printf

func (l *Logger) Printf(s string, a ...interface{})

Printf calls underlying stdlib log.Logger.Output() to print to the logger. Arguments are handled in the manner of fmt.Printf.

func (*Logger) SetIncludeCaller

func (l *Logger) SetIncludeCaller(enabled bool)

SetIncludeCaller enables/disbables logging with added caller information.

func (*Logger) SetLevel

func (l *Logger) SetLevel(lvl LEVEL)

SetLevel sets the minimum logging level for the logger.

func (*Logger) SetOutput

func (l *Logger) SetOutput(out io.Writer)

SetOutput sets the output destination for the logger.

func (*Logger) Warn

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

func (*Logger) WarnFields

func (l *Logger) WarnFields(fields ...kv.Field)

func (*Logger) Warnf

func (l *Logger) Warnf(s string, a ...interface{})

Jump to

Keyboard shortcuts

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