log

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2019 License: GPL-3.0 Imports: 7 Imported by: 31

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCtxLoggerKey = CtxLoggerKey("sm-ctx-logger")

DefaultCtxLoggerKey defines the key under which the logger is being stored

Functions

func SetLevel

func SetLevel(ctx context.Context, to zapcore.Level)

SetLevel of the logger stored in ctx

func WithFields

func WithFields(ctx context.Context, fields ...zapcore.Field) context.Context

WithFields adds all passed in zap fields to the Logger stored in ctx and overwrites it for further use

func WithLogger

func WithLogger(ctx context.Context, l *Logger) context.Context

WithLogger returns context containing Logger

Types

type CtxLoggerKey

type CtxLoggerKey string

CtxLoggerKey defines the key under which the logger is being stored

type Logger

type Logger struct {
	*zap.Logger
	Sentry *raven.Client
	Level  zap.AtomicLevel
	// contains filtered or unexported fields
}

Logger implements Context

func From

func From(ctx context.Context) *Logger

From retrieves the logger stored in context if existing or returns NopLogger otherwise

func New

func New(dsn string, local bool) (*Logger, error)

New Logger instance with an optional sentry key. If no sentry dsn is provided, the sentry encoding is disabled If local is true, logs will be provided in a human readable format, false will print stackdriver conformant logs as json

func NewNop

func NewNop() *Logger

NewNop returns Logger with empty logging, tracing and ErrorReporting

func NewWithLevel added in v1.0.3

func NewWithLevel(dsn string, local bool, level zap.AtomicLevel) (*Logger, error)

NewWithLevel builds a Logger instance with an optional sentry key and the predefined level. If no sentry dsn is provided, the sentry encoding is disabled If local is true, logs will be provided in a human readable format, false will print stackdriver conformant logs as json

func WithFieldsOverwrite

func WithFieldsOverwrite(ctx context.Context, fields ...zapcore.Field) *Logger

WithFieldsOverwrite adds all passed in zap fields to the Logger stored in ctx and overwrites it for further use WARNING: This might kill thread safety - Experimental and bad practice - DO NOT USE!

func (*Logger) IsNop

func (l *Logger) IsNop() bool

IsNop returns the nop status of Logger (mainly for testing)

func (*Logger) SetLevel

func (l *Logger) SetLevel(to zapcore.Level)

SetLevel of the underlying zap.Logger

func (*Logger) To

func (l *Logger) To(ctx context.Context) context.Context

To stores the current logger in the passed in context

func (*Logger) WithFields

func (l *Logger) WithFields(fields ...zapcore.Field) *Logger

WithFields wrapper around zap.With

func (*Logger) WithRelease

func (l *Logger) WithRelease(info string) *Logger

WithRelease returns a new logger updating the internal sentry client with release info This should be the first change to the logger (before adding fields) as otherwise the change might not be persisted

Jump to

Keyboard shortcuts

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