logi

package
v0.0.2-0...-1c7e8a7 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: Unlicense, Unlicense, ISC Imports: 11 Imported by: 0

README

Logo Logi

Logging subsystem with pretty print, code loc, channel and Writer outputs

GoDoc Go Report Card

Documentation

Index

Constants

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

Variables

View Source
var (
	Levels = []string{
		Off,
		Fatal,
		Error,
		Check,
		Warn,
		Info,
		Debug,
		Trace,
	}
	Tags = map[string]string{
		Off:   "",
		Fatal: "FTL",
		Error: "ERR",
		Check: "CHK",
		Warn:  "WRN",
		Info:  "INF",
		Debug: "DBG",
		Trace: "TRC",
	}
	LevelsMap = map[string]int{
		Off:   0,
		Fatal: 1,
		Error: 2,
		Check: 3,
		Warn:  4,
		Info:  5,
		Debug: 6,
		Trace: 7,
	}
	StartupTime = time.Now()
)

Functions

func Caller

func Caller(comment string, skip int) string

func Composite

func Composite(text, level string) (final string)

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 FileExists

func FileExists(filePath string) bool

func PickNoun

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

Types

type CheckFunc

type CheckFunc func(pkg string, err error) bool

type Entry

type Entry struct {
	Time         time.Time
	Level        string
	Package      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
	Write uberatomic.Bool
}

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{})

func (*LogWriter) SetLogWriter

func (w *LogWriter) SetLogWriter(wr io.Writer)

type Logger

type Logger struct {
	Packages        *Pk.Package
	Level           *uberatomic.String
	Fatal           PrintlnFunc
	Error           PrintlnFunc
	Warn            PrintlnFunc
	Info            PrintlnFunc
	Check           CheckFunc
	Debug           PrintlnFunc
	Trace           PrintlnFunc
	Fatalf          PrintfFunc
	Errorf          PrintfFunc
	Warnf           PrintfFunc
	Infof           PrintfFunc
	Debugf          PrintfFunc
	Tracef          PrintfFunc
	Fatalc          PrintcFunc
	Errorc          PrintcFunc
	Warnc           PrintcFunc
	Infoc           PrintcFunc
	Debugc          PrintcFunc
	Tracec          PrintcFunc
	Fatals          SpewFunc
	Errors          SpewFunc
	Warns           SpewFunc
	Infos           SpewFunc
	Debugs          SpewFunc
	Traces          SpewFunc
	LogFileHandle   *os.File
	Writer          LogWriter
	Color           bool
	Split           string
	LogChan         chan Entry
	LogChanDisabled *uberatomic.Bool
}

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

func NewLogger

func NewLogger() (l *Logger)

func (*Logger) AddLogChan

func (l *Logger) AddLogChan() (ch chan Entry)

AddLogChan adds a channel that log entries are sent to

func (*Logger) GetLoc

func (l *Logger) GetLoc(loc string, line int) (out string)

func (*Logger) LevelIsActive

func (l *Logger) LevelIsActive(level string) (out bool)

func (*Logger) LoadConfig

func (l *Logger) LoadConfig(configFile []byte)

func (*Logger) LocToPkg

func (l *Logger) LocToPkg(pkg string) (out string)

func (*Logger) Register

func (l *Logger) Register(pkg string) string

func (*Logger) SetLevel

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

func (*Logger) SetLogPaths

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

SetLogPaths sets a file path to write logs

type PrintcFunc

type PrintcFunc func(pkg string, fn func() string)

type PrintfFunc

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

type PrintlnFunc

type PrintlnFunc func(pkg string, a ...interface{})

type SpewFunc

type SpewFunc func(pkg string, a interface{})

Directories

Path Synopsis
Package Entry is a message type for logi log entries
Package Entry is a message type for logi log entries
Pkg
Package Pkg is a message type for logi package filtering
Package Pkg is a message type for logi package filtering
Pk
consume
Package consume turns off and on the Serve logging messages and provides a way to receive and process the log messages
Package consume turns off and on the Serve logging messages and provides a way to receive and process the log messages
serve
Package serve receives logi.Entry messages on a channel and sends them when it has been told to Run by Consume, and pauses when it is told Pause
Package serve receives logi.Entry messages on a channel and sends them when it has been told to Run by Consume, and pauses when it is told Pause

Jump to

Keyboard shortcuts

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