logger – github.com/gobuffalo/logger Index | Files

package logger

import "github.com/gobuffalo/logger"

Index

Constants

const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel = logrus.PanicLevel
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel = 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 = logrus.ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = logrus.WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel = logrus.InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = logrus.DebugLevel
)
const Version = "v1.0.6"

Version of the logger

Types

type FieldLogger

type FieldLogger interface {
	Logger
	WithField(string, interface{}) FieldLogger
	WithFields(map[string]interface{}) FieldLogger
}

FieldLogger interface

func New

func New(lvl Level) FieldLogger

New based on the specified log level, defaults to "debug". This logger will log to the STDOUT in a human readable, but parseable form.

Example: time="2016-12-01T21:02:07-05:00" level=info duration=225.283µs human_size="106 B" method=GET path="/" render=199.79µs request_id=2265736089 size=106 status=200

func NewLogger

func NewLogger(level string) FieldLogger

NewLogger based on the specified log level, defaults to "debug". See `New` for more details.

type Level

type Level = logrus.Level

Level of the logger

func ParseLevel

func ParseLevel(level string) (Level, error)

type Logger

type Logger interface {
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Printf(string, ...interface{})
	Warnf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
	Debug(...interface{})
	Info(...interface{})
	Warn(...interface{})
	Error(...interface{})
	Fatal(...interface{})
	Panic(...interface{})
}

Logger interface is used throughout Buffalo apps to log a whole manner of things.

type Logrus

type Logrus struct {
	logrus.FieldLogger
}

Logrus is a Logger implementation backed by sirupsen/logrus

func (Logrus) SetOutput

func (l Logrus) SetOutput(w io.Writer)

SetOutput will try and set the output of the underlying logrus.FieldLogger if it can

func (Logrus) WithField

func (l Logrus) WithField(s string, i interface{}) FieldLogger

WithField returns a new Logger with the field added

func (Logrus) WithFields

func (l Logrus) WithFields(m map[string]interface{}) FieldLogger

WithFields returns a new Logger with the fields added

type Outable

type Outable interface {
	SetOutput(out io.Writer)
}

Outable interface for loggers that allow setting the output writer

Source Files

formatter.go level.go logger.go logrus.go outable.go terminal_check.go version.go

Version
v1.0.7 (latest)
Published
Sep 3, 2022
Platform
linux/amd64
Imports
10 packages
Last checked
1 month ago

Tools for package owners.