log

package
v0.0.0-...-9bb4683 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	// With returns a logger based off the root logger and decorates it with
	// the given context and arguments.
	With(ctx context.Context, args ...interface{}) Logger

	// Debug uses fmt.Sprint to construct and log a message at DEBUG level
	Debug(args ...interface{})
	// Info uses fmt.Sprint to construct and log a message at INFO level
	Info(args ...interface{})
	// Error uses fmt.Sprint to construct and log a message at ERROR level
	Error(args ...interface{})
	// Warn uses fmt.Sprint to construct and log a message at WARN level
	Warn(args ...interface{})
	// Panic uses fmt.Sprint to construct and log a message at Panic level
	Panic(args ...interface{})

	// Debugf uses fmt.Sprintf to construct and log a message at DEBUG level
	Debugf(format string, args ...interface{})
	// Infof uses fmt.Sprintf to construct and log a message at INFO level
	Infof(format string, args ...interface{})
	// Warnf uses fmt.Sprintf to construct and log a message at WARN level
	Warnf(format string, args ...interface{})
	// Errorf uses fmt.Sprintf to construct and log a message at ERROR level
	Errorf(format string, args ...interface{})
	// Panicf uses fmt.Sprintf to construct and log a message at Panic level
	Panicf(format string, args ...interface{})
}

Logger is a logger that supports log levels, context and structured logging.

func New

func New() Logger

New creates a new logger using the default configuration.

func NewCustom

func NewCustom(level string, w io.Writer, opts []zap.Option) Logger

NewCustom creates a new logger using a custom configuration given a log level.

func NewCustomLogger

func NewCustomLogger(level string, ws []io.Writer, opts []zap.Option) Logger

func NewForTest

func NewForTest() (Logger, *observer.ObservedLogs)

NewForTest returns a new logger and the corresponding observed logs which can be used in unit tests to verify log entries.

func NewWithZap

func NewWithZap(l *zap.Logger, opts ...zap.Option) Logger

NewWithZap creates a new logger using the preconfigured zap logger.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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