logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LvlNull uint8 = iota
	LvlFatal
	LvlError
	LvlWarning
	LvlInfo
	LvlDebug
)

Variables

View Source
var (
	Debug   = func(...interface{}) {} // Trivial and aligning with best practices
	Info    = func(...interface{}) {} // Non-trivial and aligning with best practices
	Warning = func(...interface{}) {} // Non-trivial and not aligning with best practices
	Error   = func(...interface{}) {} // Important and not in good condition, system can keep up
	Fatal   = func(...interface{}) {} // Important and not in good condition, system can't keep up
)
View Source
var (
	ErrBadLoggingLvl error = errors.New("internal/logger.Init(): invalid logLevel")
)

Functions

func DebugWriter

func DebugWriter() *levelWriter

func DualLogger

func DualLogger(conf LoggerConfig, wg *sync.WaitGroup, exFn *func()) *dualLogger

func ErrorWriter

func ErrorWriter() *levelWriter

func FatalWriter

func FatalWriter() *levelWriter

func InfoWriter

func InfoWriter() *levelWriter

func Init

func Init(loggerConfig LoggerConfig) error

func InitWithWaitGroupAndExitingFunc

func InitWithWaitGroupAndExitingFunc(wg *sync.WaitGroup, exitFunc *func(), loggerConfig LoggerConfig) error

func LastWord

func LastWord(v ...interface{})

LastWord() blocks and is only used for CLEAN, INTENDED EXITING. calling LastWord() does not invoke exitingFunc() caller should make sure the system is in a CLEAN state which exit(0) could be invoked without breaking any other systems.

func NewCustomWriter

func NewCustomWriter(prefix string, suffix string) *customWriter

func WarningWriter

func WarningWriter() *levelWriter

Types

type Logger

type Logger interface {
	Debug(...interface{})
	Info(...interface{})
	Warning(...interface{})
	Error(...interface{})
	Fatal(...interface{})
	Writer(prefix string, suffix string) io.Writer
}

type LoggerConfig

type LoggerConfig struct {
	Verbose  bool   `yaml:"verbose"`
	Filepath string `yaml:"log_path"`
	Level    uint8  `yaml:"log_level"`
}

Jump to

Keyboard shortcuts

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