clog

package
v0.0.0-...-94dfbf8 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2019 License: Unlicense Imports: 3 Imported by: 1

README

clog

Clog is a logger that works by receiving strings on channels and triggering an output through a configurable output function. The log level can be changed on the fly and immediately takes effect. There is colour available for tags if desired.

See

Documentation

Index

Constants

View Source
const (
	// Nftl is the number for fatal errors
	Nftl = iota
	// Nerr is the number for errors
	Nerr
	// Nwrn is the number for warnings
	Nwrn
	// Ninf is the number for information
	Ninf
	// Ndbg is the number for debugging
	Ndbg
	// Ntrc is the number for trace
	Ntrc
)

Variables

View Source
var (

	// Ftl is for critical/fatal errors
	Ftl = &Lvl{0, ftlFn, nil}
	// Err is an error that does block continuation
	Err = &Lvl{1, errFn, nil}
	// Wrn is is a warning of a correctable condition
	Wrn = &Lvl{2, wrnFn, nil}
	// Inf is is general information
	Inf = &Lvl{3, infFn, nil}
	// Dbg is debug level information
	Dbg = &Lvl{4, dbgFn, nil}
	// Trc is detailed outputs of contents of variables
	Trc = &Lvl{5, trcFn, nil}

	// L is an array of log levels that can be selected given the level number
	L = []*Lvl{
		Ftl,
		Err,
		Wrn,
		Inf,
		Dbg,
		Trc,
	}

	// LogLevel is a dynamically settable log level filter that excludes higher values from output
	LogLevel = Trc.Num

	// Quit signals the logger to stop
	Quit = make(chan struct{})

	// LogIt is the function that performs the output, can be loaded by the caller
	LogIt = Print
)

Functions

func Check

func Check(err error, tag int, where string) (wasError bool)

Check checks if an error exists, if so, prints a log to the specified log level with a string and returns if err was nil

func Color

func Color(on bool)

Color sets whether tags are coloured or not, 0 color

func GetColor

func GetColor() bool

GetColor returns if color is turned on

func Init

func Init(fn ...func(name, txt string)) bool

Init manually starts a clog

func Print

func Print(name, txt string)

Print out a formatted log message

Types

type Lvl

type Lvl struct {
	Num  int
	Name func(c ...int) string
	Chan chan string
}

Lvl is a log level data structure

Jump to

Keyboard shortcuts

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