v0.31.1 Latest Latest

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

Go to latest
Published: Sep 6, 2023 License: Apache-2.0 Imports: 6 Imported by: 0




This section is empty.


This section is empty.


func Debug

func Debug(ctx context.Context, err error)

Debug will log err if the context has debug logging enabled.

func Debugf

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf will log the formatted string if the context has debug logging enabled.

func Log

func Log(ctx context.Context, err error)

Log will log an application error.

func Logf

func Logf(ctx context.Context, format string, args ...interface{})

Logf will log application information.

func RequestID

func RequestID(ctx context.Context) string

RequestID will return the associated RequestID or empty string if missing.

func SetRequestID

func SetRequestID(ctx context.Context) context.Context

SetRequestID will assign a unique ID to the context for tracing.

func WithDebug added in v0.29.0

func WithDebug(ctx context.Context) context.Context

WithDebug will enable debug logging for the context.

func WithField

func WithField(ctx context.Context, field string, value interface{}) context.Context

WithField will return a context with the specified field set to value.

func WithFields

func WithFields(ctx context.Context, fields Fields) context.Context

WithFields will return a context with the provided fields set.

func WithLogger added in v0.29.0

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


type Fields

type Fields map[string]interface{}

Fields are used to add values in structured logging.

func ContextFields

func ContextFields(ctx context.Context) Fields

ContextFields will return the current set of fields associated with a context.

type Logger added in v0.29.0

type Logger struct {
	// contains filtered or unexported fields

func FromContext added in v0.29.0

func FromContext(ctx context.Context) *Logger

func NewLogger added in v0.29.0

func NewLogger() *Logger

func (*Logger) AddErrorMapper added in v0.29.0

func (l *Logger) AddErrorMapper(mapper func(context.Context, error) context.Context)

func (*Logger) BackgroundContext added in v0.29.0

func (l *Logger) BackgroundContext() context.Context

func (*Logger) DebugError added in v0.29.0

func (l *Logger) DebugError(ctx context.Context, err error)

func (*Logger) DebugPrintf added in v0.29.0

func (l *Logger) DebugPrintf(ctx context.Context, format string, args ...interface{})

func (*Logger) EnableDebug added in v0.29.0

func (l *Logger) EnableDebug()

If EnableDebug is called, all debug messages will be logged.

func (*Logger) EnableJSON added in v0.29.0

func (l *Logger) EnableJSON()

EnableJSON sets the output log format to JSON

func (*Logger) EnableStacks added in v0.29.0

func (l *Logger) EnableStacks()

EnableStacks enables stack information via the Source field.

func (*Logger) Error added in v0.29.0

func (l *Logger) Error(ctx context.Context, err error)

func (*Logger) ErrorsOnly added in v0.29.0

func (l *Logger) ErrorsOnly()

ErrorsOnly will disable all log output except errors.

func (*Logger) Printf added in v0.29.0

func (l *Logger) Printf(ctx context.Context, format string, args ...interface{})

func (*Logger) SetOutput added in v0.29.0

func (l *Logger) SetOutput(out io.Writer)

SetOutput will change the log output.

func (*Logger) Write added in v0.30.0

func (l *Logger) Write(p []byte) (int, error)

Write is a pass-through for the underlying logger's Write method.

Jump to

Keyboard shortcuts

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