env_logger

package module
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: MIT Imports: 4 Imported by: 17

README

env_logger

This is a super simple project which aims to help out with setting up logging correctly in your project. It is a true drop in replacement for logrus logger atm.

Usage

The entire logging framework is configured via a single environment variable GOLANG_LOG. The variable is a comma delimited list of packages and their respective log-levels. (falling back to InfoLevel if not configured).

Examples

GOLANG_LOG=foo=debug,bar=warn go run

This configures the foo package at loglevel Debug, the bar package at loglevel Warn and the default/fallback logger at Info.

GOLANG_LOG=foo=info,debug,bar=warn go run

This is the same as the previous example, except foo is now at loglevel Info, and the default loglevel is Debug.

GOLANG_LOG=debug go run

This example sets everything to Debug.

Documentation

Index

Constants

View Source
const (
	TraceV = iota
	DebugV = iota
	InfoV  = iota
	WarnV  = iota
	ErrV   = iota
	FatalV = iota
	PanicV = iota
)

Variables

This section is empty.

Functions

func ConfigureAllLoggers

func ConfigureAllLoggers(newdefaultLogger *logrus.Logger, debugConfig string)

ConfigureLogger takes in a logger object and configures the logger depending on environment variables. Configured based on the GOLANG_DEBUG environment variable

func ConfigureInternalLogger

func ConfigureInternalLogger(newInternalLogger *logrus.Logger)

ConfigureInternalLogger instantiates a interal logger to debug the logger

func Debug

func Debug(args ...interface{})

func Debugf

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

func Debugln

func Debugln(args ...interface{})

func EnableLineNumbers

func EnableLineNumbers()

EnableLineNumbers log output of linenumbers as logerus fields

func Error

func Error(args ...interface{})

func Errorf

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

func Errorln

func Errorln(args ...interface{})

func Fatal

func Fatal(args ...interface{})

func Fatalf

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

func Fatalln

func Fatalln(args ...interface{})

func GetLoggerForPrefix

func GetLoggerForPrefix(prefix string) logrus.FieldLogger

GetLoggerForPrefix gets the logger for a certain prefix if it has been configured

func Info

func Info(args ...interface{})

func Infof

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

func Infoln

func Infoln(args ...interface{})

func Log

func Log(level logrus.Level, args ...interface{})

func Logf

func Logf(level logrus.Level, format string, args ...interface{})

func Logln

func Logln(level logrus.Level, args ...interface{})

func Must

func Must(err error)

Must Checks if an error occured, otherwise panic

func MustFatal added in v0.1.12

func MustFatal(err error)

MustFatal Checks if an error occured, otherwise stop the program

func Panic

func Panic(args ...interface{})

func Panicf

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

func Panicln

func Panicln(args ...interface{})

func Print

func Print(args ...interface{})

func Printf

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

func Println

func Println(args ...interface{})

func SetLevel

func SetLevel(level logrus.Level)

SetLevel sets the default loggers level

func Should

func Should(err error)

Should Checks if an error occured, otherwise prints it as error

func ShouldWarn

func ShouldWarn(err error)

ShouldWarn Checks if an error occured, otherwise prints it as warning

func Trace

func Trace(args ...interface{})

func Tracef

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

func Traceln

func Traceln(args ...interface{})

func Warn

func Warn(args ...interface{})

Warn prints a warning...

func Warnf

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

func Warnln

func Warnln(args ...interface{})

func WithError

func WithError(err error) *logrus.Entry

func WithField

func WithField(key string, value interface{}) *logrus.Entry

func WithFields

func WithFields(fields logrus.Fields) *logrus.Entry

Types

This section is empty.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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