log

package
v0.7.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// DefaultWindow is the default message window size for rate limiting.
	DefaultWindow = 256
	// MinimumWindow is the smallest message window size for rate limiting.
	MinimumWindow = 32
)
View Source
const (
	// DefaultLevel is the default logging severity level.
	DefaultLevel = LevelInfo
)

Variables

This section is empty.

Functions

func ClearDebugToggleSignal

func ClearDebugToggleSignal()

ClearDebugToggleSignal removes any signal handlers for toggling debug on/off.

func Configure added in v0.3.0

func Configure(cfg *cfgapi.Config) error

Configure updates the logging configuration.

func Debug

func Debug(format string, args ...interface{})

Debug formats and emits a debug message.

func DebugBlock

func DebugBlock(prefix string, format string, args ...interface{})

DebugBlock formats and emits a multiline debug message.

func DebugEnabled

func DebugEnabled(source string) bool

DebugEnabled checks if debug logging is enabled for the source.

func DisableDebug

func DisableDebug(source string) bool

DisableDebug disables debug logging for the source.

func EnableDebug

func EnableDebug(source string) bool

EnableDebug enables debug logging for the source.

func Error

func Error(format string, args ...interface{})

Error formats and emits an error message.

func ErrorBlock

func ErrorBlock(prefix string, format string, args ...interface{})

ErrorBlock formats and emits a multiline error message.

func Every

func Every(interval time.Duration) goxrate.Limit

Every defines a rate limit for the given interval.

func Fatal

func Fatal(format string, args ...interface{})

Fatal formats and emits an error message and os.Exit()'s with status 1.

func Flush

func Flush()

Flush flushes any pending log messages.

func Info

func Info(format string, args ...interface{})

Info formats and emits an informational message.

func InfoBlock

func InfoBlock(prefix string, format string, args ...interface{})

InfoBlock formats and emits a multiline information message.

func Panic

func Panic(format string, args ...interface{})

Panic formats and emits an error messages, and panics with the same.

func SetLevel

func SetLevel(level Level)

SetLevel sets the logging severity level.

func SetStdLogger

func SetStdLogger(source string)

SetStdLogger sets up a logger for the standard log package.

func SetupDebugToggleSignal

func SetupDebugToggleSignal(sig os.Signal)

SetupDebugToggleSignal sets up a signal handler to toggle full debugging on/off.

func Warn

func Warn(format string, args ...interface{})

Warn formats and emits a warning message.

func WarnBlock

func WarnBlock(prefix string, format string, args ...interface{})

WarnBlock formats and emits a multiline warning message.

Types

type Level

type Level int

Level describes the severity of a log message.

const (

	// LevelDebug is the severity for debug messages.
	LevelDebug Level
	// LevelInfo is the severity for informational messages.
	LevelInfo
	// LevelWarn is the severity for warnings.
	LevelWarn
	// LevelError is the severity for errors.
	LevelError
	// LevelPanic is the severity for panic messages.
	LevelPanic
	// LevelFatal is the severity for fatal errors.
	LevelFatal
)

func (Level) String

func (l Level) String() string

type Logger

type Logger interface {
	// Standardized Logger interface functions so that this interface can be
	// used from goresctrl library.
	Debugf(format string, v ...interface{})
	Infof(format string, v ...interface{})
	Warnf(format string, v ...interface{})
	Errorf(format string, v ...interface{})
	Panicf(format string, v ...interface{})
	Fatalf(format string, v ...interface{})

	// Debug formats and emits a debug message.
	Debug(format string, args ...interface{})
	// Info formats and emits an informational message.
	Info(format string, args ...interface{})
	// Warn formats and emits a warning message.
	Warn(format string, args ...interface{})
	// Error formats and emits an error message.
	Error(format string, args ...interface{})
	// Panic formats and emits an error message then panics with the same.
	Panic(format string, args ...interface{})
	// Fatal formats and emits an error message and os.Exit()'s with status 1.
	Fatal(format string, args ...interface{})

	// DebugBlock formats and emits a multiline debug message.
	DebugBlock(prefix string, format string, args ...interface{})
	// InfoBlock formats and emits a multiline information message.
	InfoBlock(prefix string, format string, args ...interface{})
	// WarnBlock formats and emits a multiline warning message.
	WarnBlock(prefix string, format string, args ...interface{})
	// ErrorBlock formats and emits a multiline error message.
	ErrorBlock(prefix string, format string, args ...interface{})

	// EnableDebug enables debug messages for this Logger.
	EnableDebug(bool) bool
	// DebugEnabled checks if debug messages are enabled for this Logger.
	DebugEnabled() bool

	// Source returns the source name of this Logger.
	Source() string
}

Logger is the interface for producing log messages for/from a particular source.

func Default

func Default() Logger

Default returns the default Logger.

func Get

func Get(source string) Logger

Get returns the named Logger.

func NewLogger

func NewLogger(source string) Logger

NewLogger creates the named logger.

func RateLimit

func RateLimit(log Logger, rate Rate) Logger

RateLimit returns a ratelimited version of the given logger.

type Rate

type Rate struct {
	// rate limit
	Limit goxrate.Limit
	// allowed bursts
	Burst int
	// optional message window size
	Window int
}

Rate specifies maximum per-message logging rate.

func Interval

func Interval(interval time.Duration) Rate

Interval returns a Rate for the given interval.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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