log

package
v0.2.17 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2019 License: Unlicense Imports: 10 Imported by: 2

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()
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 Composite

func Composite(text, level string, color bool) string

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 Print

func Print(a ...interface{})

func Printf

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

func Println

func Println(a ...interface{})

func SPEW

func SPEW(a interface{})

func SetLogWriter

func SetLogWriter(w io.Writer)

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 LogWriter

type LogWriter struct {
	io.Writer
}

func (*LogWriter) Print

func (w *LogWriter) Print(a ...interface{})

func (*LogWriter) Printf

func (w *LogWriter) Printf(format string, a ...interface{})

func (*LogWriter) Println

func (w *LogWriter) Println(a ...interface{})

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
	Writer        LogWriter
	Color         bool
	// If this channel is loaded log entries are composed and sent to it
	LogChan chan Entry
}

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)

type PrintfFunc

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

type PrintlnFunc

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

type SpewFunc

type SpewFunc *func(interface{})

Jump to

Keyboard shortcuts

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