log

package
v0.0.0-...-94820cb Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 License: Unlicense Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Off   = "off"
	Fatal = "fatal"
	Error = "error"
	Warn  = "warn"
	Info  = "info"
	Debug = "debug"
	Trace = "trace"
)

Variables

View Source
var L = Empty().SetLevel("off", true)
View Source
var Levels = []string{
	Off, Fatal, Error, Warn, Info, Debug, Trace,
}
View Source
var NoClosure = func() PrintcFunc {
	f := func(_ func() string) {
	}
	return &f
}
View Source
var NoPrintf = func() PrintfFunc {
	f := func(_ string, _ ...interface{}) {
	}
	return &f
}
View Source
var NoPrintln = func() PrintlnFunc {
	f := func(_ ...interface{}) {
	}
	return &f
}
View Source
var NoSpew = func() SpewFunc {
	f := func(_ interface{}) {
	}
	return &f
}
View Source
var StartupTime = time.Now()

Functions

func DEBUG

func DEBUG(a ...interface{})

func DEBUGC

func DEBUGC(fn func() string)

func DEBUGF

func DEBUGF(format string, a ...interface{})

func DirectionString

func DirectionString(inbound bool) string

DirectionString is a helper function that returns a string that represents the direction of a connection (inbound or outbound).

func ERROR

func ERROR(a ...interface{})

func ERRORC

func ERRORC(fn func() string)

func ERRORF

func ERRORF(format string, a ...interface{})

func FATAL

func FATAL(a ...interface{})

func FATALC

func FATALC(fn func() string)

func FATALF

func FATALF(format string, a ...interface{})

func FileExists

func FileExists(filePath string) bool

FileExists reports whether the named file or directory exists.

func INFO

func INFO(a ...interface{})

func INFOC

func INFOC(fn func() string)

func INFOF

func INFOF(format string, a ...interface{})

func PickNoun

func PickNoun(n int, singular, plural string) string

PickNoun returns the singular or plural form of a noun depending on the count n.

func SPEW

func SPEW(a interface{})

func TRACE

func TRACE(a ...interface{})

func TRACEC

func TRACEC(fn func() string)

func TRACEF

func TRACEF(format string, a ...interface{})

func WARN

func WARN(a ...interface{})

func WARNC

func WARNC(fn func() string)

func WARNF

func WARNF(format string, a ...interface{})

Types

type Entry

type Entry struct {
	Time         time.Time
	Level        string
	CodeLocation string
	Text         string
}

Entry is a log entry to be printed as json to the log file

type Logger

type Logger struct {
	Fatal         PrintlnFunc
	Error         PrintlnFunc
	Warn          PrintlnFunc
	Info          PrintlnFunc
	Debug         PrintlnFunc
	Trace         PrintlnFunc
	Traces        SpewFunc
	Fatalf        PrintfFunc
	Errorf        PrintfFunc
	Warnf         PrintfFunc
	Infof         PrintfFunc
	Debugf        PrintfFunc
	Tracef        PrintfFunc
	Fatalc        PrintcFunc
	Errorc        PrintcFunc
	Warnc         PrintcFunc
	Infoc         PrintcFunc
	Debugc        PrintcFunc
	Tracec        PrintcFunc
	LogFileHandle *os.File
	Color         bool
}

Logger is a struct containing all the functions with nice handy names

func Empty

func Empty() *Logger

func (*Logger) SetLevel

func (l *Logger) SetLevel(level string, color bool) *Logger

SetLevel enables or disables the various print functions

func (*Logger) SetLogPaths

func (l *Logger) SetLogPaths(logPath, logFileName string)

SetLogPaths sets a file path to write logs

type PrintcFunc

type PrintcFunc *func(func() string)

func Printc

func Printc(level string, color bool, fh *os.File) PrintcFunc

Printc prints from a closure returning a string

type PrintfFunc

type PrintfFunc *func(format string, a ...interface{})

func Printf

func Printf(level string, color bool, fh *os.File) PrintfFunc

Printf prints a log entry with formatting

type PrintlnFunc

type PrintlnFunc *func(a ...interface{})

func Println

func Println(level string, color bool, fh *os.File) PrintlnFunc

Println prints a log entry like Println

type SpewFunc

type SpewFunc *func(interface{})

func Prints

func Prints(level string, color bool, fh *os.File) SpewFunc

Prints spews a variable

Jump to

Keyboard shortcuts

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