logx

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Overview

Package logx contains logging extensions.

Package logx contains logging extensions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler struct {
	// Emoji is OPTIONAL and indicates whether to enable emojis.
	Emoji bool

	// Now is the MANDATORY function to compute the current time.
	Now func() time.Time

	// StartTime is MANDATORY and indicates when we started logging.
	StartTime time.Time

	// Writer is MANDATORY and is the underlying writer.
	io.Writer
}

Handler implements github.com/apex/log.Handler.

func NewHandlerWithDefaultSettings

func NewHandlerWithDefaultSettings() *Handler

NewHandlerWithDefaultSettings creates a new Handler with default settings.

func (*Handler) HandleLog

func (h *Handler) HandleLog(e *log.Entry) (err error)

HandleLog implements log.Handler

type OperationLogger added in v0.26.0

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

OperationLogger keeps state required to log about an in-progress operation as documented by NewOperationLogger.

func NewOperationLogger added in v0.26.0

func NewOperationLogger(logger model.Logger, format string, v ...any) *OperationLogger

NewOperationLogger creates a new logger that logs about an in-progress operation. If it takes too much time to emit the result of the operation, the code will emit an interim log message mentioning that the operation is currently in progress.

func (*OperationLogger) Stop added in v0.26.0

func (ol *OperationLogger) Stop(value any)

Stop must be called when the operation is done. The [value] argument is the result of the operation, which may be nil. This method ensures that we log the final result of the now-completed operation.

type PrefixLogger added in v0.26.0

type PrefixLogger struct {
	Prefix string
	Logger model.Logger
}

PrefixLogger is a logger with a prefix.

func (*PrefixLogger) Debug added in v0.26.0

func (p *PrefixLogger) Debug(msg string)

Debug implements DebugLogger.Debug

func (*PrefixLogger) Debugf added in v0.26.0

func (p *PrefixLogger) Debugf(format string, v ...interface{})

Debugf implements DebugLogger.Debugf

func (*PrefixLogger) Info added in v0.26.0

func (p *PrefixLogger) Info(msg string)

Info implements InfoLogger.Info

func (*PrefixLogger) Infof added in v0.26.0

func (p *PrefixLogger) Infof(format string, v ...interface{})

Infov implements InfoLogger.Infov

func (*PrefixLogger) Warn added in v0.26.0

func (p *PrefixLogger) Warn(msg string)

Warn implements Logger.Warn

func (*PrefixLogger) Warnf added in v0.26.0

func (p *PrefixLogger) Warnf(format string, v ...interface{})

Warnf implements Logger.Warnf

type ScrubberLogger added in v0.26.0

type ScrubberLogger struct {
	// Logger is the MANDATORY underlying logger to use.
	Logger model.Logger
}

ScrubberLogger is a model.Logger with scrubbing. All messages are scrubbed including the ones that won't be emitted. As such, this logger is less efficient than a logger without scrubbing.

The zero value is invalid; please init all MANDATORY fields.

func (*ScrubberLogger) Debug added in v0.26.0

func (sl *ScrubberLogger) Debug(message string)

Debug scrubs and emits a debug message.

func (*ScrubberLogger) Debugf added in v0.26.0

func (sl *ScrubberLogger) Debugf(format string, v ...interface{})

Debugf scrubs, formats, and emits a debug message.

func (*ScrubberLogger) Info added in v0.26.0

func (sl *ScrubberLogger) Info(message string)

Info scrubs and emits an informational message.

func (*ScrubberLogger) Infof added in v0.26.0

func (sl *ScrubberLogger) Infof(format string, v ...interface{})

Infof scrubs, formats, and emits an informational message.

func (*ScrubberLogger) Warn added in v0.26.0

func (sl *ScrubberLogger) Warn(message string)

Warn scrubs and emits a warning message.

func (*ScrubberLogger) Warnf added in v0.26.0

func (sl *ScrubberLogger) Warnf(format string, v ...interface{})

Warnf scrubs, formats, and emits a warning message.

Jump to

Keyboard shortcuts

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