loggers

package
v0.112.7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 11 Imported by: 59

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Counts ERROR logs to the global jww logger.
	GlobalErrorCounter *jww.Counter
	PanicOnWarning     atomic.Bool
)

Functions

func InitGlobalLogger added in v0.54.0

func InitGlobalLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer)

InitGlobalLogger initializes the global logger, used in some rare cases.

func LoggerToWriterWithPrefix added in v0.75.0

func LoggerToWriterWithPrefix(logger *log.Logger, prefix string) io.Writer

func RemoveANSIColours added in v0.99.0

func RemoveANSIColours(s string) string

RemoveANSIColours removes all ANSI colours from the given string.

Types

type IgnorableLogger added in v0.73.0

type IgnorableLogger interface {
	Logger
	Errorsf(statementID, format string, v ...any)
	Apply(logger Logger) IgnorableLogger
}

IgnorableLogger is a logger that ignores certain log statements.

func NewIgnorableLogger added in v0.73.0

func NewIgnorableLogger(logger Logger, statements map[string]bool) IgnorableLogger

NewIgnorableLogger wraps the given logger and ignores the log statement IDs given.

type LogCounters added in v0.77.0

type LogCounters struct {
	ErrorCounter *jww.Counter
	WarnCounter  *jww.Counter
}

type Logger added in v0.54.0

type Logger interface {
	Printf(format string, v ...any)
	Println(v ...any)
	PrintTimerIfDelayed(start time.Time, name string)
	Debug() *log.Logger
	Debugf(format string, v ...any)
	Debugln(v ...any)
	Info() *log.Logger
	Infof(format string, v ...any)
	Infoln(v ...any)
	Warn() *log.Logger
	Warnf(format string, v ...any)
	Warnln(v ...any)
	Error() *log.Logger
	Errorf(format string, v ...any)
	Errorln(v ...any)
	Errors() string

	Out() io.Writer

	Reset()

	// Used in tests.
	LogCounters() *LogCounters
}

func NewBasicLogger added in v0.75.0

func NewBasicLogger(t jww.Threshold) Logger

NewBasicLogger creates a new basic logger writing to Stdout.

func NewBasicLoggerForWriter added in v0.75.0

func NewBasicLoggerForWriter(t jww.Threshold, w io.Writer) Logger

NewBasicLoggerForWriter creates a new basic logger writing to w.

func NewDebugLogger

func NewDebugLogger() Logger

NewDebugLogger is a convenience function to create a debug logger.

func NewErrorLogger

func NewErrorLogger() Logger

NewErrorLogger is a convenience function to create an error logger.

func NewInfoLogger added in v0.75.0

func NewInfoLogger() Logger

NewInfoLogger is a convenience function to create a info logger.

func NewLogger added in v0.54.0

func NewLogger(stdoutThreshold, logThreshold jww.Threshold, outHandle, logHandle io.Writer, saveErrors bool) Logger

NewLogger creates a new Logger for the given thresholds

func NewWarningLogger

func NewWarningLogger() Logger

NewWarningLogger is a convenience function to create a warning logger.

Jump to

Keyboard shortcuts

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