logger

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 3 Imported by: 12 modules, 9 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

View Source
const (
	// MaxDepthBacktraceStack defines the maximum back trace depth in logger
	MaxDepthBacktraceStack = 8
)

Variables

This section is empty.

Functions

func Error

func Error(err error) zap.Field

func Int

func Int(k string, v int) zap.Field

func String

func String(k, v string) zap.Field

func Uint32

func Uint32(k string, v uint32) zap.Field

Types

type Logger

type Logger interface {
	// These are ops that call directly to the actual zap implementation
	Debug(string, ...zap.Field)
	Info(string, ...zap.Field)
	Warn(string, ...zap.Field)
	Error(string, ...zap.Field)
	Panic(string, ...zap.Field)
	Fatal(string, ...zap.Field)

	// These are the equivalent logger function but with context provided
	DebugWithContext(context.Context, string, ...zap.Field)
	InfoWithContext(context.Context, string, ...zap.Field)
	WarnWithContext(context.Context, string, ...zap.Field)
	ErrorWithContext(context.Context, string, ...zap.Field)
	PanicWithContext(context.Context, string, ...zap.Field)
	FatalWithContext(context.Context, string, ...zap.Field)
}

type ZapLogger

type ZapLogger struct {
	*zap.Logger
}

ZapLogger is an implementation of Logger that uses the uber/zap logger underneath. It provides additional methods such as ones that logs based on context.

func NewJSONLogger added in v0.1.1

func NewJSONLogger() (*ZapLogger, error)

func NewNoopLogger

func NewNoopLogger() *ZapLogger

NewNoopLogger provides noop logger that satisfies the logger interface.

func NewTextLogger added in v0.1.1

func NewTextLogger() (*ZapLogger, error)

func (*ZapLogger) Debug

func (l *ZapLogger) Debug(msg string, fields ...zap.Field)

func (*ZapLogger) DebugWithContext

func (l *ZapLogger) DebugWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) Error

func (l *ZapLogger) Error(msg string, fields ...zap.Field)

func (*ZapLogger) ErrorWithContext

func (l *ZapLogger) ErrorWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) Fatal

func (l *ZapLogger) Fatal(msg string, fields ...zap.Field)

func (*ZapLogger) FatalWithContext

func (l *ZapLogger) FatalWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) Info

func (l *ZapLogger) Info(msg string, fields ...zap.Field)

func (*ZapLogger) InfoWithContext

func (l *ZapLogger) InfoWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) Panic

func (l *ZapLogger) Panic(msg string, fields ...zap.Field)

func (*ZapLogger) PanicWithContext

func (l *ZapLogger) PanicWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) Warn

func (l *ZapLogger) Warn(msg string, fields ...zap.Field)

func (*ZapLogger) WarnWithContext

func (l *ZapLogger) WarnWithContext(ctx context.Context, msg string, fields ...zap.Field)

func (*ZapLogger) With

func (l *ZapLogger) With(fields ...zap.Field)

Jump to

Keyboard shortcuts

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