log

package module
v0.0.0-...-78145d0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

README

go-logging

A simple logging utility because that is definitely what the world needed: another logger.

Output

The output follows this structure:

%time	%level	%caller	…

%time is in the format

%level is colored by default when logging to stdout or stderr and not on Windows. It can be enabled and disabled at will.

%caller is the name (format: package.function) of the function that is logging the message

Levels

Level Description
TRACE Print everything. This is usually not wanted unless debugging.
DEBUG Print every function call.
INFO Print general statusmessages like HTTP-Requests (a good default)
WARN Handled errors.
ERROR Non-Critical Errors like access denied
FATAL Errors that do not allow the Program to continue

License

The code is Licensed under the MPL 2.0

Copyright (c) 2020 Moritz Poldrack

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Colorfuncs = [...]func(...interface{}) string{
	ansi.Blue,
	ansi.Cyan,
	ansi.Green,
	ansi.Yellow,
	ansi.Red,
	fatalStyle,
}

ColorFuncs contains the functions to color in the Levels

View Source
var KeptLogs = uint(10)
View Source
var LevelStrings = [...]string{
	"TRACE",
	"DEBUG",
	"INFO ",
	"WARN ",
	"ERROR",
	"FATAL",
}

LevelStrings allows for easy renaming of Levels

View Source
var TimeFormat = "2006-01-02 15:04:05"

TimeFormat sets the used timeformat. The default is DDMMYYYYHHMMSS

Functions

This section is empty.

Types

type Level

type Level uint8
const (
	TRACE Level = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
)

func (Level) String

func (lvl Level) String() string

type Logger

type Logger struct {
	// Loglevel sets the minimum severity to log messages
	Loglevel Level
	// Colorize sets whether log-Levels are colored
	Color bool
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger() *Logger

func (*Logger) Debug

func (l *Logger) Debug(input ...interface{})

func (*Logger) Debugf

func (l *Logger) Debugf(input ...interface{})

func (*Logger) Error

func (l *Logger) Error(input ...interface{})

func (*Logger) Errorf

func (l *Logger) Errorf(input ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(input ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(input ...interface{})

func (*Logger) Info

func (l *Logger) Info(input ...interface{})

func (*Logger) Infof

func (l *Logger) Infof(input ...interface{})

func (*Logger) Rotate

func (l *Logger) Rotate(ctx context.Context, maxSize int64, maxAge time.Duration, delay time.Duration)

func (*Logger) SetOutput

func (l *Logger) SetOutput(path string) error

func (*Logger) Trace

func (l *Logger) Trace(input ...interface{})

func (*Logger) Tracef

func (l *Logger) Tracef(input ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(input ...interface{})

func (*Logger) Warnf

func (l *Logger) Warnf(input ...interface{})

Jump to

Keyboard shortcuts

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