log

package module
v0.0.0-...-38d2e2c Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2020 License: Apache-2.0 Imports: 11 Imported by: 85

README

log

A simple logger for Go with rich data structure support.

Documentation

Index

Constants

View Source
const (
	// ErrorLabel is a label for a Error message.
	ErrorLabel = "✖"
	// DebugLabel is a label for a debug message.
	DebugLabel = "▶"
	// DumpLabel is a label for a dump message.
	DumpLabel = "▼"
	// InfoLabel is a label for an informative message.
	InfoLabel = "ℹ"
	// SuccessLabel is a label for a success message.
	SuccessLabel = "✔"
	// WarningLabel is a label for a warning message.
	WarningLabel = "!"
)

Variables

View Source
var (
	// GlobalLevel to log at. Defaults to info level.
	GlobalLevel = InfoLevel
	// Color should be enabled for logs.
	Color = true
	// TestMode is enabled.
	TestMode = false
	// Timestamps should be printed.
	Timestamps = false
)
View Source
var DefaultLogger = &Logger{
	Level: InfoLevel,
	Color: true,
}

DefaultLogger is the default logger.

Functions

func Break

func Break()

Break prints a break in the logs.

func BreakHard

func BreakHard()

BreakHard prints a hard break in the logs.

func BreakPound

func BreakPound()

BreakPound prints a pound break in the logs.

func BreakStar

func BreakStar()

BreakStar prints a star break in the logs.

func Check

func Check(err error)

Check if an error is nil otherwise log fatal.

func Debug

func Debug(a ...interface{})

Debug message.

func Debugf

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

Debugf is a formatted Debug message.

func Debugv

func Debugv(name string, value interface{})

Debugv prints value in a k:v fromat.

func Debugvb

func Debugvb(name string, value interface{})

Debugvb prints value in a k:v fromat with the value on a new line.

func Debugy

func Debugy(name string, obj interface{})

Debugy prints the YAML represtation of an object at Debug level.

func Dump

func Dump(a ...interface{})

Dump message.

func Dumpf

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

Dumpf is a formatted Dump message.

func Dumpv

func Dumpv(name string, value interface{})

Dumpv prints value in a k:v fromat.

func Dumpvb

func Dumpvb(name string, value interface{})

Dumpvb prints value in a k:v fromat with the value on a new line.

func Dumpy

func Dumpy(name string, obj interface{})

Dumpy prints the YAML represtation of an object at Dump level.

func Error

func Error(a ...interface{})

Error message.

func Errorf

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

Errorf is a formatted Error message.

func Errorv

func Errorv(name string, value interface{})

Errorv prints value in a k:v fromat.

func Errorvb

func Errorvb(name string, value interface{})

Errorvb prints value in a k:v fromat with the value on a new line.

func Errory

func Errory(name string, obj interface{})

Errory prints the YAML represtation of an object at Error level.

func Fatal

func Fatal(a ...interface{})

Fatal logs Error message then exits with code 1.

func Fatalf

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

Fatalf message logs formatted Error then exits with code 1.

func Fatalv

func Fatalv(v ...interface{})

Fatalv prints values in a k:v fromat and then exists with code 1.

func Fataly

func Fataly(name string, obj interface{})

Fataly prints the YAML represtation of an object at Error level then exits with code 1.

func Info

func Info(a ...interface{})

Info message.

func Infof

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

Infof is a formatted Info message.

func Infov

func Infov(name string, value interface{})

Infov prints value in a k:v fromat.

func Infovb

func Infovb(name string, value interface{})

Infovb prints value in a k:v fromat with the value on a new line.

func Infoy

func Infoy(name string, obj interface{})

Infoy prints the YAML represtation of an object at Info level.

func MarshalJSON

func MarshalJSON(a interface{}) (b []byte, err error)

MarshalJSON marshals either a proto message or any other interface.

func PrintYAML

func PrintYAML(a interface{}) error

PrintYAML prints the YAML string of an object and has support for proto messages.

func SPrintYAML

func SPrintYAML(a interface{}) (string, error)

SPrintYAML returns a YAML string for an object and has support for proto messages.

func Success

func Success(a ...interface{})

Success message.

func Successf

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

Successf is a formatted Success message.

func Successv

func Successv(name string, value interface{})

Successv prints value in a k:v fromat.

func Successvb

func Successvb(name string, value interface{})

Successvb prints value in a k:v fromat with the value on a new line.

func Successy

func Successy(name string, obj interface{})

Successy prints the YAML represtation of an object at Success level.

func Warning

func Warning(a ...interface{})

Warning message.

func Warningf

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

Warningf is a formatted Warning message.

func Warningv

func Warningv(name string, value interface{})

Warningv prints value in a k:v fromat.

func Warningvb

func Warningvb(name string, value interface{})

Warningvb prints value in a k:v fromat with the value on a new line.

func Warningy

func Warningy(name string, obj interface{})

Warningy prints the YAML represtation of an object at Warning level.

Types

type Level

type Level int

Level is a log level.

const (
	// ErrorLevel logging.
	ErrorLevel Level = 1
	// WarningLevel logging.
	WarningLevel Level = 2
	// InfoLevel logging.
	InfoLevel Level = 3
	// DebugLevel logging.
	DebugLevel Level = 4
	// DumpLevel logging.
	DumpLevel Level = 5
)

type Logger

type Logger struct {
	// Level to log at. Defaults to info level.
	Level Level

	// Color should be enabled for logs.
	Color bool

	// TestMode is enabled.
	TestMode bool

	// Timestamps should be printed.
	Timestamps bool
}

Logger is a logger.

func NewLogger

func NewLogger(level Level, color bool) *Logger

NewLogger is a new logger.

func (*Logger) Break

func (l *Logger) Break()

Break prints a break in the logs.

func (*Logger) BreakHard

func (l *Logger) BreakHard()

BreakHard prints a hard break in the logs.

func (*Logger) BreakPound

func (l *Logger) BreakPound()

BreakPound prints a pound break in the logs.

func (*Logger) BreakStar

func (l *Logger) BreakStar()

BreakStar prints a star break in the logs.

func (*Logger) Debug

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

Debug message.

func (*Logger) Debugf

func (l *Logger) Debugf(format string, a ...interface{})

Debugf is a formatted Debug message.

func (*Logger) Debugv

func (l *Logger) Debugv(name string, value interface{})

Debugv prints value in a k:v fromat.

func (*Logger) Debugvb

func (l *Logger) Debugvb(name string, value interface{})

Debugvb prints value in a k:v fromat with the value on a new line.

func (*Logger) Debugy

func (l *Logger) Debugy(name string, obj interface{})

Debugy prints the YAML represtation of an object at Debug level.

func (*Logger) Dump

func (l *Logger) Dump(a ...interface{})

Dump message.

func (*Logger) Dumpf

func (l *Logger) Dumpf(format string, a ...interface{})

Dumpf is a formatted Dump message.

func (*Logger) Dumpv

func (l *Logger) Dumpv(name string, value interface{})

Dumpv prints value in a k:v fromat.

func (*Logger) Dumpvb

func (l *Logger) Dumpvb(name string, value interface{})

Dumpvb prints value in a k:v fromat with the value on a new line.

func (*Logger) Dumpy

func (l *Logger) Dumpy(name string, obj interface{})

Dumpy prints the YAML represtation of an object at Dump level.

func (*Logger) Error

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

Error message.

func (*Logger) Errorf

func (l *Logger) Errorf(format string, a ...interface{})

Errorf is a formatted Error message.

func (*Logger) Errorv

func (l *Logger) Errorv(name string, value interface{})

Errorv prints value in a k:v fromat.

func (*Logger) Errorvb

func (l *Logger) Errorvb(name string, value interface{})

Errorvb prints value in a k:v fromat with the value on a new line.

func (*Logger) Errory

func (l *Logger) Errory(name string, obj interface{})

Errory prints the YAML represtation of an object at Error level.

func (*Logger) Fatal

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

Fatal logs Error message then exits with code 1.

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, a ...interface{})

Fatalf message logs formatted Error then exits with code 1.

func (*Logger) Fatalv

func (l *Logger) Fatalv(v ...interface{})

Fatalv prints values in a k:v fromat and then exists with code 1.

func (*Logger) Fataly

func (l *Logger) Fataly(name string, obj interface{})

Fataly prints the YAML represtation of an object at Error level then exits with code 1.

func (*Logger) Info

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

Info message.

func (*Logger) Infof

func (l *Logger) Infof(format string, a ...interface{})

Infof is a formatted Info message.

func (*Logger) Infov

func (l *Logger) Infov(name string, value interface{})

Infov prints value in a k:v fromat.

func (*Logger) Infovb

func (l *Logger) Infovb(name string, value interface{})

Infovb prints value in a k:v fromat with the value on a new line.

func (*Logger) Infoy

func (l *Logger) Infoy(name string, obj interface{})

Infoy prints the YAML represtation of an object at Info level.

func (*Logger) Success

func (l *Logger) Success(a ...interface{})

Success message.

func (*Logger) Successf

func (l *Logger) Successf(format string, a ...interface{})

Successf is a formatted Success message.

func (*Logger) Successv

func (l *Logger) Successv(name string, value interface{})

Successv prints value in a k:v fromat.

func (*Logger) Successvb

func (l *Logger) Successvb(name string, value interface{})

Successvb prints value in a k:v fromat with the value on a new line.

func (*Logger) Successy

func (l *Logger) Successy(name string, obj interface{})

Successy prints the YAML represtation of an object at Success level.

func (*Logger) Warning

func (l *Logger) Warning(a ...interface{})

Warning message.

func (*Logger) Warningf

func (l *Logger) Warningf(format string, a ...interface{})

Warningf is a formatted Warning message.

func (*Logger) Warningv

func (l *Logger) Warningv(name string, value interface{})

Warningv prints value in a k:v fromat.

func (*Logger) Warningvb

func (l *Logger) Warningvb(name string, value interface{})

Warningvb prints value in a k:v fromat with the value on a new line.

func (*Logger) Warningy

func (l *Logger) Warningy(name string, obj interface{})

Warningy prints the YAML represtation of an object at Warning level.

Jump to

Keyboard shortcuts

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