log

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package log defines the Logger interfaces

Index

Constants

View Source
const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel = Level(logrus.PanicLevel)
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel = Level(logrus.FatalLevel)
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel = Level(logrus.ErrorLevel)
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel = Level(logrus.WarnLevel)
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel = Level(logrus.InfoLevel)
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel = Level(logrus.DebugLevel)
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel = Level(logrus.TraceLevel)
)
View Source
const (
	// AlwaysLevel is a level to indicate we want to always log
	AlwaysLevel = Level(0)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Level

type Level logrus.Level

Level defines a type for log levels

func ParseLevel

func ParseLevel(level string) (Level, error)

ParseLevel returns a Level from its string representation

type LoggedError

type LoggedError struct {
	Err error
}

LoggedError indicates an error that has been already logged

func (*LoggedError) Error

func (e *LoggedError) Error() string

Error returns the wrapped error

func (*LoggedError) Unwrap

func (e *LoggedError) Unwrap() error

Unwrap returns the wrapped error

type LoggedProgressBar

type LoggedProgressBar struct {
	Logger
	// contains filtered or unexported fields
}

LoggedProgressBar defines a widget that supports the ProgressBar interface but just logs messages

func NewLoggedProgressBar

func NewLoggedProgressBar(l Logger) *LoggedProgressBar

NewLoggedProgressBar returns a progress bar that just log messages

func (*LoggedProgressBar) Add

func (p *LoggedProgressBar) Add(steps int) ProgressBar

Add increments the progress bar the specified amount

func (*LoggedProgressBar) Error

func (p *LoggedProgressBar) Error(fmt string, args ...interface{})

Error shows an error message

func (*LoggedProgressBar) Info

func (p *LoggedProgressBar) Info(fmt string, args ...interface{})

Info shows an info message

func (*LoggedProgressBar) Start

func (p *LoggedProgressBar) Start(...interface{}) (ProgressBar, error)

Start initiates the progress bar

func (*LoggedProgressBar) Stop

func (p *LoggedProgressBar) Stop()

Stop stops the progress bar

func (*LoggedProgressBar) Successf

func (p *LoggedProgressBar) Successf(fmt string, args ...interface{})

Successf displays a success message

func (*LoggedProgressBar) UpdateTitle

func (p *LoggedProgressBar) UpdateTitle(str string) ProgressBar

UpdateTitle updates the progress bar title

func (*LoggedProgressBar) Warning

func (p *LoggedProgressBar) Warning(fmt string, args ...interface{})

Warning displays a warning message

func (*LoggedProgressBar) WithTotal

func (p *LoggedProgressBar) WithTotal(steps int) ProgressBar

WithTotal sets the progress bar total steps

type Logger

type Logger interface {
	Infof(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Debugf(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Printf(format string, args ...interface{})
	SetWriter(w io.Writer)
	SetLevel(level Level)
	Failf(format string, args ...interface{}) error
}

Logger defines a common interface for loggers

type ProgressBar

type ProgressBar interface {
	WithTotal(total int) ProgressBar
	UpdateTitle(title string) ProgressBar
	Add(increment int) ProgressBar
	Start(title ...interface{}) (ProgressBar, error)
	Stop()
	Successf(fmt string, args ...interface{})
	Errorf(fmt string, args ...interface{})
	Infof(fmt string, args ...interface{})
	Warnf(fmt string, args ...interface{})
}

ProgressBar defines a ProgressBar widget

type SectionLogger

type SectionLogger interface {
	Logger
	Successf(format string, args ...interface{})
	PrefixText(string) string
	StartSection(title string) SectionLogger
	//	Nest(title string) SectionLogger
	//	NestLevel() int
	Section(title string, fn func(SectionLogger) error) error
	ExecuteStep(title string, fn func() error) error
	ProgressBar() ProgressBar
}

SectionLogger defines an interface for loggers supporting nested levels of loggin

Directories

Path Synopsis
Package logrus provides a logger implementation using the logrus library
Package logrus provides a logger implementation using the logrus library
Package pterm provides a logger implementation using the pterm library
Package pterm provides a logger implementation using the pterm library
Package silent implements a silent logger
Package silent implements a silent logger

Jump to

Keyboard shortcuts

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