log

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyFormatting

func ApplyFormatting(text string, formats ...ShellFormatting) string

func FormatText

func FormatText(text string, formats ...ShellFormatting) string

Format text using the provided directives. Append a reset directive, so following text will not be formatted. Use ApplyFormatting if this is not wanted.

func JSON

func JSON(level LogLevel, message string, fields map[string]string) []byte

func ResetFormatting

func ResetFormatting(text string) string

func ShellColoredLevels

func ShellColoredLevels(level LogLevel, message string, fields map[string]string) []byte

func StreamReaderNewLines

func StreamReaderNewLines(logger func(message string, fields ...string), reader io.Reader)

Stream every newline as a new INFO-level entry.

Types

type LogFormatter

type LogFormatter = func(level LogLevel, message string, fields map[string]string) []byte

type LogLevel

type LogLevel byte
const (
	TRACE   LogLevel = 1
	DEBUG   LogLevel = 2
	INFO    LogLevel = 3
	WARNING LogLevel = 4
	ERROR   LogLevel = 5
	FATAL   LogLevel = 6
)

func GetLogLevel

func GetLogLevel() LogLevel

type Logger

type Logger struct {
	Level     LogLevel
	Formatter LogFormatter
	// contains filtered or unexported fields
}

func DefaultLogger

func DefaultLogger() *Logger

func NamedLogger

func NamedLogger(name string) *Logger

func NewLogger

func NewLogger(name string, level LogLevel, formatter LogFormatter, stdout, stderr io.Writer) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string, fields ...string)

func (*Logger) Error

func (l *Logger) Error(msg string, fields ...string)

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, fields ...string)

func (*Logger) Info

func (l *Logger) Info(msg string, fields ...string)

func (*Logger) Panic

func (l *Logger) Panic(msg string, fields ...string)

func (*Logger) Trace

func (l *Logger) Trace(msg string, fields ...string)

func (*Logger) Warning

func (l *Logger) Warning(msg string, fields ...string)

func (*Logger) With

func (l *Logger) With(fields ...string) *Logger

type ShellFormatting

type ShellFormatting int
const (
	Reset ShellFormatting = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)
const (
	FgBlack ShellFormatting = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground text colors

const (
	FgHiBlack ShellFormatting = iota + 90
	FgHiRed
	FgHiGreen
	FgHiYellow
	FgHiBlue
	FgHiMagenta
	FgHiCyan
	FgHiWhite
)

Foreground Hi-Intensity text colors

const (
	BgBlack ShellFormatting = iota + 40
	BgRed
	BgGreen
	BgYellow
	BgBlue
	BgMagenta
	BgCyan
	BgWhite
)

Background text colors

const (
	BgHiBlack ShellFormatting = iota + 100
	BgHiRed
	BgHiGreen
	BgHiYellow
	BgHiBlue
	BgHiMagenta
	BgHiCyan
	BgHiWhite
)

Background Hi-Intensity text colors

type TabulatedRow

type TabulatedRow struct {
	// contains filtered or unexported fields
}

func TabulateRow

func TabulateRow() TabulatedRow

func (TabulatedRow) Delimiter

func (t TabulatedRow) Delimiter(delimiter string) TabulatedRow

func (TabulatedRow) Field

func (t TabulatedRow) Field(text string, width int, formatting ...ShellFormatting) TabulatedRow

func (TabulatedRow) String

func (t TabulatedRow) String() string

Jump to

Keyboard shortcuts

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