common

package
v0.0.0-...-95fccb6 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(errorHandler ErrorHandler, err error)

HandleError wraps ErrorHandler and Errors to perform additional tasks, such as sending an error to Sentry before sending it on to the error handler

Types

type ErrorHandler

type ErrorHandler interface {
	Handle(err error)
	HandleContext(ctx context.Context, err error)
}

ErrorHandler handles an error.

type Logger

type Logger interface {
	// Trace logs a trace event.
	Trace(msg string, fields ...map[string]interface{})

	// Debug logs a debug event.
	Debug(msg string, fields ...map[string]interface{})

	// Info logs an info event.
	Info(msg string, fields ...map[string]interface{})

	// Warn logs a warning event.
	Warn(msg string, fields ...map[string]interface{})

	// Error logs an error event.
	Error(msg string, fields ...map[string]interface{})

	// TraceContext logs a trace event with a context.
	TraceContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// DebugContext logs a debug event with a context.
	DebugContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// InfoContext logs an info event with a context.
	InfoContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// WarnContext logs a warning event with a context.
	WarnContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// ErrorContext logs an error event with a context.
	ErrorContext(ctx context.Context, msg string, fields ...map[string]interface{})

	// WithFields annotates a logger with key-value pairs.
	WithFields(fields map[string]interface{}) Logger

	// WithContext annotates a logger with a context.
	WithContext(ctx context.Context) Logger
}

Logger is the fundamental interface for all log operations.

type NoopErrorHandler

type NoopErrorHandler struct{}

NoopErrorHandler is an error handler that discards every error.

func (NoopErrorHandler) Handle

func (NoopErrorHandler) Handle(_ error)

Handle ignore

func (NoopErrorHandler) HandleContext

func (NoopErrorHandler) HandleContext(_ context.Context, _ error)

HandleContext ignore

type NoopLogger

type NoopLogger struct{}

NoopLogger is a logger that discards every log event.

func (NoopLogger) Debug

func (NoopLogger) Debug(_ string, _ ...map[string]interface{})

Debug ignore

func (NoopLogger) DebugContext

func (NoopLogger) DebugContext(_ context.Context, _ string, _ ...map[string]interface{})

DebugContext ignore

func (NoopLogger) Error

func (NoopLogger) Error(_ string, _ ...map[string]interface{})

Error ignore

func (NoopLogger) ErrorContext

func (NoopLogger) ErrorContext(_ context.Context, _ string, _ ...map[string]interface{})

ErrorContext ignore

func (NoopLogger) Info

func (NoopLogger) Info(_ string, _ ...map[string]interface{})

Info ignore

func (NoopLogger) InfoContext

func (NoopLogger) InfoContext(_ context.Context, _ string, _ ...map[string]interface{})

InfoContext ignore

func (NoopLogger) Trace

func (NoopLogger) Trace(_ string, _ ...map[string]interface{})

Trace ignore

func (NoopLogger) TraceContext

func (NoopLogger) TraceContext(_ context.Context, _ string, _ ...map[string]interface{})

TraceContext ignore

func (NoopLogger) Warn

func (NoopLogger) Warn(_ string, _ ...map[string]interface{})

Warn ignore

func (NoopLogger) WarnContext

func (NoopLogger) WarnContext(_ context.Context, _ string, _ ...map[string]interface{})

WarnContext ignore

func (NoopLogger) WithContext

func (n NoopLogger) WithContext(_ context.Context) Logger

WithContext ignore

func (NoopLogger) WithFields

func (n NoopLogger) WithFields(_ map[string]interface{}) Logger

WithFields ignore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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