log

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

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 12 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultStyleSheet = StyleSheet{
	Colors: map[Category]Color{
		"debug": White,
		"warn":  Yellow,
		"error": Red,
	},

	TimeColor: Cyan,

	BarCaseLeft:  '[',
	BarCaseRight: ']',

	BarLiquid: '=',
	BarVoid:   ' ',

	BarHead: []rune{'|', '╱', '─', '╲'},

	HeadOscillation: 300 * time.Millisecond,
}
View Source
var ErrNoConsole = errors.New("log: no console to use progress bar on")

Functions

func Dump

func Dump(name string, object any)

Show a formatted representation of an object to the default logger

func Err

func Err(args ...any)

Prints 1+ error messages to the default logger

func Fatal

func Fatal(args ...any)

Crash the program, providing 1+ error messages

func FatalDump

func FatalDump(name string, object any)

Show a formatted object representation before crashing the program

func Printf

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

Prints a formatted string to default logger

func Println

func Println(args ...any)

Prints 1+ items to default logger

func Sprint

func Sprint(args ...any) string

func Sprintf

func Sprintf(format string, args ...any) string

func StartProgressBar

func StartProgressBar(pb *ProgressBar)

func Warn

func Warn(args ...any)

Prints a warning to the default logger

Types

type Category

type Category string

type Color

type Color color.Attribute

type Console

type Console interface {
	Output
	AddProgressBar(pb *ProgressBar) error
	RemoveProgressBar(pb *ProgressBar) error
}

type ConsoleOutput

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

func (*ConsoleOutput) AddLine

func (w *ConsoleOutput) AddLine(l *Line) error

func (*ConsoleOutput) AddProgressBar

func (w *ConsoleOutput) AddProgressBar(pb *ProgressBar) error

func (*ConsoleOutput) Begin

func (w *ConsoleOutput) Begin(l *Logger) error

func (*ConsoleOutput) End

func (w *ConsoleOutput) End() error

func (*ConsoleOutput) Exclude

func (w *ConsoleOutput) Exclude(cat Category) error

func (*ConsoleOutput) Include

func (w *ConsoleOutput) Include(cat Category) error

func (*ConsoleOutput) RemoveProgressBar

func (w *ConsoleOutput) RemoveProgressBar(pb *ProgressBar) error

type DirOutput

type DirOutput struct {
	Dir string
	// contains filtered or unexported fields
}

func (*DirOutput) AddLine

func (do *DirOutput) AddLine(ln *Line) error

func (*DirOutput) Begin

func (do *DirOutput) Begin(l *Logger) error

func (*DirOutput) End

func (do *DirOutput) End() error

func (*DirOutput) Exclude

func (do *DirOutput) Exclude(cat Category) error

func (*DirOutput) Include

func (do *DirOutput) Include(cat Category) error

type Line

type Line struct {
	Time     time.Time
	Category Category
	Text     string
	Fatal    bool
}

func NewDumpLine

func NewDumpLine(name string, cat Category, object any) *Line

type Logger

type Logger struct {
	StyleSheet StyleSheet
	Outputs    []Output
}
var DefaultLogger Logger

func (*Logger) AddOutput

func (l *Logger) AddOutput(op Output) error

func (*Logger) CatPrintf

func (l *Logger) CatPrintf(cat Category, format string, args ...any)

func (*Logger) ExcludeConsole

func (l *Logger) ExcludeConsole(cat Category)

func (*Logger) ExcludeDir

func (l *Logger) ExcludeDir(cat Category)

func (*Logger) GetConsole

func (l *Logger) GetConsole() *ConsoleOutput

func (*Logger) GetDir

func (l *Logger) GetDir() *DirOutput

func (*Logger) IncludeConsole

func (l *Logger) IncludeConsole(cat Category)

func (*Logger) IncludeDir

func (l *Logger) IncludeDir(cat Category)

func (*Logger) LogLine

func (l *Logger) LogLine(ln *Line)

func (*Logger) Printf

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

func (*Logger) Println

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

func (*Logger) RemoveProgressBar

func (l *Logger) RemoveProgressBar(pb *ProgressBar) error

func (*Logger) StartProgressBar

func (l *Logger) StartProgressBar(pb *ProgressBar) error

type Output

type Output interface {
	Begin(lgr *Logger) error
	End() error
	AddLine(l *Line) error
	Include(cat Category) error
	Exclude(cat Category) error
}

type ProgressBar

type ProgressBar struct {
	Range ProgressRange
	Title string
	// contains filtered or unexported fields
}

func NewFloatProgressBar

func NewFloatProgressBar(title string, min, max float64) *ProgressBar

func NewIntProgressBar

func NewIntProgressBar(title string, min, max int64) *ProgressBar

func (*ProgressBar) Complete

func (pb *ProgressBar) Complete() error

func (*ProgressBar) SetFloat

func (pb *ProgressBar) SetFloat(f float64)

func (*ProgressBar) SetInt

func (pb *ProgressBar) SetInt(i int64)

type ProgressFloat

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

func (*ProgressFloat) MinMax

func (pf *ProgressFloat) MinMax() (string, string)

func (*ProgressFloat) PercentValue

func (pf *ProgressFloat) PercentValue() float64

func (*ProgressFloat) SetFloat

func (pf *ProgressFloat) SetFloat(f float64)

func (*ProgressFloat) SetInt

func (pf *ProgressFloat) SetInt(i int64)

func (*ProgressFloat) Value

func (pf *ProgressFloat) Value() string

type ProgressInt

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

func (*ProgressInt) MinMax

func (pi *ProgressInt) MinMax() (string, string)

func (*ProgressInt) PercentValue

func (pi *ProgressInt) PercentValue() float64

func (*ProgressInt) SetFloat

func (pi *ProgressInt) SetFloat(f float64)

func (*ProgressInt) SetInt

func (pi *ProgressInt) SetInt(i int64)

func (*ProgressInt) Value

func (pi *ProgressInt) Value() string

type ProgressRange

type ProgressRange interface {
	MinMax() (string, string)
	PercentValue() float64
	Value() string
	SetFloat(f float64)
	SetInt(i int64)
}

type StyleSheet

type StyleSheet struct {
	Colors map[Category]Color

	TimeColor Color // color of timestamp

	BarCaseLeft  rune   // '['
	BarCaseRight rune   // ']'
	BarLiquid    rune   // '='
	BarVoid      rune   // ' '
	BarHead      []rune // { '>' }

	HeadOscillation time.Duration // time needed to increment the barhead index
}

Jump to

Keyboard shortcuts

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