logger

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

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

Errorf logs error message.

func ErrorfSkipframes

func ErrorfSkipframes(skipframes int, format string, args ...interface{})

ErrorfSkipframes logs error message and skips the given number of frames for the caller.

func Fatalf

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

Fatalf logs fatal message and terminates the app.

func Infof

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

Infof logs info message.

func Init

func Init()

Init initializes the logger.

Init must be called after flag.Parse()

There is no need in calling Init from tests.

func Panicf

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

Panicf logs panic message and panics.

func ResetOutputForTest

func ResetOutputForTest()

ResetOutputForTest set logger output to default value

func SetOutputForTests

func SetOutputForTests(writer io.Writer)

SetOutputForTests redefine output for logger. Use for Tests only. Call ResetOutputForTest to return output state to default

func StdErrorLogger

func StdErrorLogger() *log.Logger

StdErrorLogger returns standard error logger.

func Warnf

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

Warnf logs warn message.

func WarnfSkipframes

func WarnfSkipframes(skipframes int, format string, args ...interface{})

WarnfSkipframes logs warn message and skips the given number of frames for the caller.

Types

type LogThrottler

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

LogThrottler is a logger, which throttles log messages passed to Warnf and Errorf.

LogThrottler must be created via WithThrottler() call.

func WithThrottler

func WithThrottler(name string, throttle time.Duration) *LogThrottler

WithThrottler returns a logger throttled by time - only one message in throttle duration will be logged.

New logger is created only once for each unique name passed. The function is thread-safe.

func (*LogThrottler) Errorf

func (lt *LogThrottler) Errorf(format string, args ...interface{})

Errorf logs error message.

func (*LogThrottler) Warnf

func (lt *LogThrottler) Warnf(format string, args ...interface{})

Warnf logs warn message.

Jump to

Keyboard shortcuts

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