console

package module
v0.0.0-...-b48fc1b Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: MIT Imports: 15 Imported by: 25

Documentation

Index

Constants

View Source
const (
	NONE  = 0
	LEVEL = 1 << iota
	TIME
	FILE
)

Variables

View Source
var DefaultLogger = NewLogger()
View Source
var Pretty pretty

Functions

func Debug

func Debug(v ...any)

func Debugf

func Debugf(format string, v ...any)

func Error

func Error(v ...any)

func Errorf

func Errorf(format string, v ...any)

func Exit

func Exit(v ...any)

func Info

func Info(v ...any)

func Infof

func Infof(format string, v ...any)

func NewList

func NewList() *list

func NewTable

func NewTable() *table

func OneLine

func OneLine(format string, v ...any)

func Printf

func Printf(format string, v ...any)

func Println

func Println(v ...any)

func Warning

func Warning(v ...any)

func Warningf

func Warningf(format string, v ...any)

Types

type Color

type Color int
const (
	Reset Color = iota
	Bold
	Faint
	Italic
	Underline
	BlinkSlow
	BlinkRapid
	ReverseVideo
	Concealed
	CrossedOut
)

Base colors -- attributes in reality

const (
	FgBlack Color = iota + 30
	FgRed
	FgGreen
	FgYellow
	FgBlue
	FgMagenta
	FgCyan
	FgWhite
)

Foreground colors

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

Foreground Hi-Intensity colors

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

Background colors

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

Background Hi-Intensity colors

func (Color) Mixed

func (c Color) Mixed(color ...Color) Colors

func (Color) Print

func (c Color) Print(v ...any)

func (Color) Printf

func (c Color) Printf(format string, v ...any)

func (Color) Println

func (c Color) Println(v ...any)

func (Color) Sprint

func (c Color) Sprint(v ...any) string

func (Color) Sprintf

func (c Color) Sprintf(format string, v ...any) string

type Colors

type Colors []Color

func (Colors) Print

func (c Colors) Print(v ...any)

func (Colors) Printf

func (c Colors) Printf(format string, v ...any)

func (Colors) Println

func (c Colors) Println(v ...any)

func (Colors) Sprint

func (c Colors) Sprint(v ...any) string

func (Colors) Sprintf

func (c Colors) Sprintf(format string, v ...any) string

type Entry

type Entry struct {
	Level  Level     `json:"level,omitempty"`
	File   string    `json:"file,omitempty"`
	Line   int       `json:"line,omitempty"`
	Time   time.Time `json:"time,omitempty"`
	Format string    `json:"format"`
	Fields []Field   `json:"fields,omitempty"`
	Args   []any     `json:"args"`
}

type Field

type Field struct {
	Key   string
	Value any
}

type Formatter

type Formatter interface {
	Format(entry *Entry) string
}

type Hook

type Hook interface {
	Fire(entry *Entry)
}

type JsonFormatter

type JsonFormatter struct{}

func NewJsonFormatter

func NewJsonFormatter() *JsonFormatter

func (*JsonFormatter) Format

func (f *JsonFormatter) Format(entry *Entry) string

type Level

type Level string
const (
	ERR Level = "ERR"
	INF Level = "INF"
	DEB Level = "DEB"
	WAR Level = "WAR"
)

type Logger

type Logger struct {
	Hook         Hook
	Formatter    Formatter
	Flags        int
	InfoColor    Color
	WarningColor Color
	DebugColor   Color
	ErrorColor   Color
	Colorful     bool
	Fields       []Field
	Stdout       io.Writer
	Stderr       io.Writer
	Deep         int
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger() *Logger

func (*Logger) AddField

func (l *Logger) AddField(key string, value any)

func (*Logger) Debug

func (l *Logger) Debug(args ...any)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...any)

func (*Logger) Error

func (l *Logger) Error(args ...any)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...any)

func (*Logger) Info

func (l *Logger) Info(args ...any)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...any)

func (*Logger) SetFields

func (l *Logger) SetFields(fields ...Field)

func (*Logger) Warning

func (l *Logger) Warning(args ...any)

func (*Logger) Warningf

func (l *Logger) Warningf(format string, args ...any)

type SortMode

type SortMode int
const (
	// Asc sorts the column in Ascending order alphabetically.
	Asc SortMode = iota
	// AscNumeric sorts the column in Ascending order numerically.
	AscNumeric
	// Dsc sorts the column in Descending order alphabetically.
	Dsc
	// DscNumeric sorts the column in Descending order numerically.
	DscNumeric
)

type TextFormatter

type TextFormatter struct{}

func NewTextFormatter

func NewTextFormatter() *TextFormatter

func (*TextFormatter) Format

func (f *TextFormatter) Format(entry *Entry) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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