logz

package
v0.0.0-...-eccc266 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func FromCtx

func FromCtx(ctx context.Context) []any

func GetVer

func GetVer() string

func ParseFlag

func ParseFlag(level string) error

ParseFlag sets logging level to "level", see zapcore.Level for possible values.

func SetVer

func SetVer(v string)

SetVer sets input as the value for "v" field (version) in log entries.

func WithCtx

func WithCtx(ctx context.Context, keysAndValues ...any) context.Context

WithCtx sets key-value pairs to add as fields to log entries.

Types

type Log

type Log struct {
	*zap.SugaredLogger
}

func NewLogger

func NewLogger(c *conf.Config) (*Log, func(), error)

func (*Log) Debugw

func (l *Log) Debugw(ctx context.Context, msg string, keysAndValues ...interface{})

func (*Log) Errorw

func (l *Log) Errorw(ctx context.Context, err error, msg string, keysAndValues ...interface{}) error

func (*Log) Infof

func (l *Log) Infof(ctx context.Context, msg string, args ...interface{})

func (*Log) Infow

func (l *Log) Infow(ctx context.Context, msg string, keysAndValues ...interface{})

func (*Log) Named

func (l *Log) Named(name string) Logger

func (*Log) Printf

func (l *Log) Printf(s string, i ...interface{})

Printf is for stdlib compatibility, logging at level INFO.

func (*Log) Warnw

func (l *Log) Warnw(ctx context.Context, msg string, keysAndValues ...interface{})

func (*Log) With

func (l *Log) With(args ...interface{}) Logger

type Logger

type Logger interface {
	Named(name string) Logger
	With(args ...interface{}) Logger
	Debugw(ctx context.Context, msg string, keysAndValues ...interface{})
	Infow(ctx context.Context, msg string, keysAndValues ...interface{})
	Infof(ctx context.Context, msg string, args ...interface{})
	Warnw(ctx context.Context, msg string, keysAndValues ...interface{})
	Errorw(ctx context.Context, err error, msg string, keysAndValues ...interface{}) error
	Printf(s string, i ...interface{})
}

type TestLogger

type TestLogger struct {
	testing.TB
	*Log
	Messages []string
}

TestLogger records output to internal Messages slice for later inspection. Use in your tests.

func NewTestLogger

func NewTestLogger(tb testing.TB) *TestLogger

func (*TestLogger) AssertMessages

func (t *TestLogger) AssertMessages(msgs ...string)

func (*TestLogger) Logf

func (t *TestLogger) Logf(format string, args ...interface{})

Jump to

Keyboard shortcuts

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