logger

package
v0.0.0-...-3f0f60f Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Critical

func Critical(l Logger, args ...interface{})

Critical emits critical level logs (a remapping of zap.DPanicLevel) or falls back to error level with a '[crit]' prefix.

func Criticalf

func Criticalf(l Logger, format string, values ...interface{})

Criticalf emits critical level logs (a remapping of zap.DPanicLevel) or falls back to error level with a '[crit]' prefix.

func Criticalw

func Criticalw(l Logger, msg string, keysAndValues ...interface{})

Criticalw emits critical level logs (a remapping of zap.DPanicLevel) or falls back to error level with a '[crit]' prefix.

func NewOCRWrapper

func NewOCRWrapper(l Logger, trace bool, saveError func(string)) ocrtypes.Logger

NewOCRWrapper returns a new ocrtypes.Logger backed by the given Logger. Note: trace logs are written at debug level, regardless of any build tags.

Types

type Config

type Config struct {
	Level zapcore.Level
}

func (*Config) New

func (c *Config) New() (Logger, error)

New returns a new Logger for Config.

type Logger

type Logger interface {
	Name() string

	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Panic(args ...interface{})
	Fatal(args ...interface{})

	Debugf(format string, values ...interface{})
	Infof(format string, values ...interface{})
	Warnf(format string, values ...interface{})
	Errorf(format string, values ...interface{})
	Panicf(format string, values ...interface{})
	Fatalf(format string, values ...interface{})

	Debugw(msg string, keysAndValues ...interface{})
	Infow(msg string, keysAndValues ...interface{})
	Warnw(msg string, keysAndValues ...interface{})
	Errorw(msg string, keysAndValues ...interface{})
	Panicw(msg string, keysAndValues ...interface{})
	Fatalw(msg string, keysAndValues ...interface{})

	Sync() error
}

Logger is a minimal subset of GoPlugin/pluginV2Lib/pluginV2/core/logger.Logger implemented by go.uber.org/zap.SugaredLogger

func Helper

func Helper(l Logger, skip int) Logger

Helper returns a logger with 'skip' levels of callers skipped, if 'l' has a method `Helper(int) L`, where L implements Logger, otherwise it returns l. See zap.AddCallerSkip

func Named

func Named(l Logger, n string) Logger

Named returns a logger with name 'n', if 'l' has a method `Named(string) L`, where L implements Logger, otherwise it returns l.

func New

func New() (Logger, error)

New returns a new Logger with the default configuration.

func NewWith

func NewWith(cfgFn func(*zap.Config)) (Logger, error)

NewWith returns a new Logger from a modified zap.Config.

func Nop

func Nop() Logger

Nop returns a no-op Logger.

func Test

func Test(tb testing.TB) Logger

Test returns a new test Logger for tb.

func TestObserved

func TestObserved(tb testing.TB, lvl zapcore.Level) (Logger, *observer.ObservedLogs)

TestObserved returns a new test Logger for tb and ObservedLogs at the given Level.

func With

func With(l Logger, keyvals ...interface{}) Logger

With returns a Logger with keyvals, if 'l' has a method `With(...interface{}) L`, where L implements Logger, otherwise it returns l.

type SugaredLogger

type SugaredLogger interface {
	Logger
	// ErrorIf logs the error if present.
	ErrorIf(err error, msg string)
	// ErrorIfFn calls fn() and logs any returned error along with msg.
	// Unlike ErrorIf, this can be deffered inline, since the function call is delayed.
	ErrorIfFn(fn func() error, msg string)
}

SugaredLogger extends the base Logger interface with syntactic sugar, similar to zap.SugaredLogger.

func Sugared

func Sugared(l Logger) SugaredLogger

Sugared returns a new SugaredLogger wrapping the given Logger.

Jump to

Keyboard shortcuts

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