logger

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger ...

Package logger ...

Package logger ...

Package logger ...

Package logger ...

Package logger ...

Package logger ...

Package logger ...

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Formatter

type Formatter interface {
	Format(*LogEntry, bool) string
	FormatList(*LogEntry) string
}

Formatter is the interface defining the methods to be implemented by a printer.

type LogEntry

type LogEntry struct {
	Logger  *Logger
	Level   LogLevel
	Message string
	Entries []LogEntry
	// contains filtered or unexported fields
}

LogEntry represents a single log entry.

func NewLogEntry

func NewLogEntry(logger *Logger) *LogEntry

NewLogEntry returns a new entry.

func (*LogEntry) Append

func (item *LogEntry) Append(level LogLevel, msg string)

Append add an entry to the `entries`.

func (*LogEntry) Debug

func (item *LogEntry) Debug(msg string)

Debug level message.

func (*LogEntry) Debugf

func (item *LogEntry) Debugf(msg string, v ...interface{})

Debugf level formatted message.

func (*LogEntry) Error

func (item *LogEntry) Error(msg string)

Error level message.

func (*LogEntry) Errorf

func (item *LogEntry) Errorf(msg string, v ...interface{})

Errorf level formatted message.

func (*LogEntry) Fatal

func (item *LogEntry) Fatal(msg string)

Fatal level message.

func (*LogEntry) Fatalf

func (item *LogEntry) Fatalf(msg string, v ...interface{})

Fatalf level formatted message.

func (*LogEntry) Important

func (item *LogEntry) Important(msg string)

Important level message.

func (*LogEntry) Importantf

func (item *LogEntry) Importantf(msg string, v ...interface{})

Importantf level formatted message.

func (*LogEntry) Indent

func (item *LogEntry) Indent()

Indent add a string as prefix when indent list entries.

func (*LogEntry) Info

func (item *LogEntry) Info(msg string)

Info level message.

func (*LogEntry) Infof

func (item *LogEntry) Infof(msg string, v ...interface{})

Infof level formatted message.

func (*LogEntry) SetIndentChar

func (item *LogEntry) SetIndentChar(c string)

SetIndentChar sets the char used as prefix when indent list entries. Whitespace as default.

func (*LogEntry) SetIndentSize

func (item *LogEntry) SetIndentSize(size int)

SetIndentSize sets how many time the indent char has to be repeated when indent list entries.

func (*LogEntry) String

func (item *LogEntry) String() string

String returns the entry as string.

func (*LogEntry) Success

func (item *LogEntry) Success(msg string)

Success level message.

func (*LogEntry) Successf

func (item *LogEntry) Successf(msg string, v ...interface{})

Successf level formatted message.

func (*LogEntry) Unindent

func (item *LogEntry) Unindent()

Unindent resets the indent size.

func (*LogEntry) Warning

func (item *LogEntry) Warning(msg string)

Warning level message.

func (*LogEntry) Warningf

func (item *LogEntry) Warningf(msg string, v ...interface{})

Warningf level formatted message.

func (*LogEntry) WithList

func (item *LogEntry) WithList() *LogEntry

WithList returns a new entry with `entries` set.

type LogLevel

type LogLevel int

LogLevel represents the level of severity.

const (
	LevelPanic LogLevel = iota
	LevelFatal
	LevelError
	LevelWarning
	LevelInfo
	LevelSuccess
	LevelDebug
	LevelImportant
	LevelDefault
)

Log Levels.

func (LogLevel) String

func (level LogLevel) String() string

String returns the log level as string.

type Logger

type Logger struct {
	Printer Printer
	Level   LogLevel
}

Logger represents a logger with configurable Printer and Level.

func New

func New() *Logger

New returns a new logger.

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug level message.

func (*Logger) Debugf

func (l *Logger) Debugf(msg string, v ...interface{})

Debugf level formatted message.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error level message.

func (*Logger) Errorf

func (l *Logger) Errorf(msg string, v ...interface{})

Errorf level formatted message.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

Fatal level message.

func (*Logger) Fatalf

func (l *Logger) Fatalf(msg string, v ...interface{})

Fatalf level formatted message.

func (*Logger) Important

func (l *Logger) Important(msg string)

Important level message.

func (*Logger) Importantf

func (l *Logger) Importantf(msg string, v ...interface{})

Importantf level formatted message.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info level message.

func (*Logger) Infof

func (l *Logger) Infof(msg string, v ...interface{})

Infof level formatted message.

func (*Logger) SetLevel

func (l *Logger) SetLevel(level LogLevel)

SetLevel sets the logger Level.

func (*Logger) SetPrinter

func (l *Logger) SetPrinter(printer Printer)

SetPrinter set the logger Printer.

func (*Logger) Success

func (l *Logger) Success(msg string)

Success level message.

func (*Logger) Successf

func (l *Logger) Successf(msg string, v ...interface{})

Successf level formatted message.

func (*Logger) Warning

func (l *Logger) Warning(msg string)

Warning level message.

func (*Logger) Warningf

func (l *Logger) Warningf(msg string, v ...interface{})

Warningf level formatted message.

func (*Logger) WithList

func (l *Logger) WithList() *LogEntry

WithList returns a new entry with `entries` set.

type Printer

type Printer interface {
	Print(string)
	SetPrinterOptions(options *PrinterOptions)
	Formatter
}

Printer is the interface defining the methods to be implemented by a printer.

type PrinterOptions

type PrinterOptions struct {
	Timestamp       bool
	TimestampFormat string
	Colors          bool
	Labels          bool
	Icons           bool
}

PrinterOptions represents the valid options for a printer.

type TextPrinter

type TextPrinter struct {
	Options *PrinterOptions
}

TextPrinter sets stdout as printer.

func (*TextPrinter) Format

func (tp *TextPrinter) Format(item *LogEntry, isWithList bool) string

Format defines how a single log entry will be formatted by the TextLogger printer.

func (*TextPrinter) FormatList

func (tp *TextPrinter) FormatList(item *LogEntry) string

FormatList defines how a log entry with List will be formatted by the TextLogger printer.

func (*TextPrinter) Print

func (tp *TextPrinter) Print(msg string)

Print send the message string to the stdout.

func (*TextPrinter) SetPrinterOptions

func (tp *TextPrinter) SetPrinterOptions(options *PrinterOptions)

SetPrinterOptions sets the printer options for TextPrinter.

Jump to

Keyboard shortcuts

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