logging

package
v0.0.0-...-c797b29 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigureDevLogger

func ConfigureDevLogger() *zap.Logger

func ConfigureProdLogger

func ConfigureProdLogger() *zap.Logger

func ConfigureZapGlobals

func ConfigureZapGlobals()

func ImbueContext

func ImbueContext(ctx context.Context, logger *zap.Logger) context.Context

func L

func L(ctx context.Context, opts ...zap.Option) *zap.Logger

func MakeFieldsUnique

func MakeFieldsUnique(reorderLoggedFields bool) zap.Option

func NewPrettyConsoleEncoder

func NewPrettyConsoleEncoder(cfg zapcore.EncoderConfig) zapcore.Encoder

NewPrettyConsoleEncoder creates an encoder whose output is designed for human - rather than machine - consumption. It serializes the core log entry data (message, level, timestamp, etc.) in a plain-text format and leaves the structured context as a pretty-printed multiline JSON.

Additional functionality includes easily-readable stack traces.

Note that while pretty-printing is useful in development, it's bad for production

func SL

func SL(ctx context.Context, opts ...zap.Option) *zap.SugaredLogger

func TryGetLoggerFromContext

func TryGetLoggerFromContext(ctx context.Context) *zap.Logger

func WithFields

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

Types

type MemorySink

type MemorySink struct {
	bytes.Buffer
}

MemorySink implements zap.Sink by writing all messages to a buffer.

func NewMemorySinkLogger

func NewMemorySinkLogger() (*MemorySink, *zap.Logger)

func (*MemorySink) Close

func (s *MemorySink) Close() error

func (*MemorySink) Sync

func (s *MemorySink) Sync() error

type ShortenedStackTrace

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

func NewShortenedStackTrace

func NewShortenedStackTrace(skipFrames int, skipToFirstPanic bool,
	msg interface{}) *ShortenedStackTrace

NewShortenedStackTrace creates a new shortened stack trace, that can optionally skip all the frames after the first panic() call (typically deferred error handlers).

func (*ShortenedStackTrace) Error

func (s *ShortenedStackTrace) Error() string

func (*ShortenedStackTrace) Field

func (s *ShortenedStackTrace) Field() zap.Field

func (*ShortenedStackTrace) JSONStack

func (s *ShortenedStackTrace) JSONStack() []StackElement

JSONStack creates a nice stack trace, skipping all the deferred frames after the first panic() call. This method returns the list of structures that can be nicely reflected into JSON.

func (*ShortenedStackTrace) StackTrace

func (s *ShortenedStackTrace) StackTrace() []uintptr

func (*ShortenedStackTrace) StringStack

func (s *ShortenedStackTrace) StringStack() string

StringStack creates a nice stack trace, skipping all the deferred frames after the first panic() call. This method returns a human-readable multi-line string.

type StackElement

type StackElement struct {
	Fl string
	Fn string
}

Jump to

Keyboard shortcuts

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