zephyrus

package
v1.0.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package zephyrus 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

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

type Field struct {
	Key   string
	Value interface{}
}

Field represents a logger field.

type Logger

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

func NewLoggerFromContext(ctx context.Context) *Logger

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

func (*Logger) Clean

func (l *Logger) Clean()

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

func (*Logger) Debug

func (l *Logger) Debug(msg string)

Debug logs a Debug level message.

func (*Logger) Error

func (l *Logger) Error(msg string)

Error logs a Error level message.

func (*Logger) Fatal

func (l *Logger) Fatal(msg string)

Fatal logs a Fatal message.

func (*Logger) Info

func (l *Logger) Info(msg string)

Info logs a Info level message.

func (*Logger) Warn

func (l *Logger) Warn(msg string)

Warn logs a Warning level message.

func (*Logger) WithError

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

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

WithField returns a logger with the provided field.

func (*Logger) WithFields

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

WithFields returns a logger with the providedfields.

type Options

type Options struct {
}

Options is the logger options. TODO: Adapt to zap.Options

Jump to

Keyboard shortcuts

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