logger

package
v0.0.0-...-a7a3610 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2019 License: Apache-2.0 Imports: 11 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Testing    = false
	TestBuffer *bytes.Buffer
)

Test specific variables, these should never be set unless from within a test file.

Functions

func ConfigureTargets

func ConfigureTargets(targets interface{}) io.Writer

ConfigureTargets takes a 'JSON' map that defines what log targets there should be and converts them into an io.Writer suitable for being the target of a logrus.Output, this can be a io.MultiWriter or just a writer

Types

type Fields

type Fields map[string]interface{}

Fields is a map containing any fields to log with.

type Log

type Log interface {
	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalln(args ...interface{})
	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})
	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
	Panicln(args ...interface{})
	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Println(args ...interface{})
	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warning(args ...interface{})
	Warningf(format string, args ...interface{})
	Warningln(args ...interface{})
	Warnln(args ...interface{})
	WithError(err error) Log
	WithField(key string, value interface{}) Log
	WithFields(fields Fields) Log
	SetLevel(LogLevel)
	SetOut(io.Writer)
}

Log wraps a series of logging fields that should be implemented on any log type.

func New

func New() Log

New will return an instance of the log utility that should be used for send messages to the user. PREFER LogWithSource.

func NewWithSource

func NewWithSource(source string) Log

NewWithSource returns a log with a predefined "source" field attached to it. This should be the primary method used to fetch a logger for use in other parts fo the code.

func TestLog

func TestLog() Log

TestLog should never be called in normal code, it's purpose is to bypass the logger generated from configuration settings

type LogLevel

type LogLevel uint8
const (
	PanicLevel LogLevel = 1 + iota
	FatalLevel
	ErrorLevel
	WarnLevel
	InfoLevel
	DebugLevel
)

Log level definitions for the Log interface

func GetLogLevel

func GetLogLevel(level string) LogLevel

GetLogLevel converts a string value to a logrus.Level value for use in providing configuration for the logger from the Gamefile.

Jump to

Keyboard shortcuts

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