log

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package log provides commonly used logging functions by wrapping the uber-go/zap package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContextWithLogger added in v0.0.3

func NewContextWithLogger(parentCtx context.Context, logger *Logger) context.Context

NewContextWithLogger returns a new context with a logger and panics if it doesn't match the interface.

Types

type Field added in v0.0.2

type Field struct {
	Key   string
	Value interface{}
}

Field represents a logger field.

type Logger added in v0.0.3

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

Logger wraps zap.Logger.

func New

func New(ctx context.Context, debug bool) (*Logger, error)

New creates a new logger. Make sure to call defer logger.Clean() after calling this. TODO: Benchmarking

func NewLoggerFromContext added in v0.0.3

func NewLoggerFromContext(ctx context.Context) *Logger

NewLoggerFromContext retrieves a logger from a context and panics if there isn't one.

func (*Logger) Clean added in v0.0.3

func (l *Logger) Clean()

Clean cleans up the log states. Make sure to call this after creating a new logger.

func (*Logger) Debug added in v0.0.3

func (l *Logger) Debug(msg string)

Debug logs a Debug level message.

func (*Logger) Error added in v0.0.3

func (l *Logger) Error(msg string)

Error logs a Error level message.

func (*Logger) Fatal added in v0.0.3

func (l *Logger) Fatal(msg string)

Fatal logs a Fatal message.

func (*Logger) Info added in v0.0.3

func (l *Logger) Info(msg string)

Info logs a Info level message.

func (*Logger) Warn added in v0.0.3

func (l *Logger) Warn(msg string)

Warn logs a Warning level message.

func (*Logger) WithError added in v0.0.3

func (l *Logger) WithError(err error) *Logger

WithError returns a logger with the current error padded. TODO: How to append this error?

func (*Logger) WithField added in v0.0.3

func (l *Logger) WithField(key string, val interface{}) *Logger

WithField returns a logger with the provided field.

func (*Logger) WithFields added in v0.0.3

func (l *Logger) WithFields(fields []Field) *Logger

WithFields returns a logger with the providedfields.

type Options added in v0.0.3

type Options struct {
}

Options is the logger options.

Jump to

Keyboard shortcuts

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