log

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Debug = "DEBUG"
	Info  = "INFO"
	Warn  = "WARN"
	Error = "ERROR"
)

Variables

This section is empty.

Functions

func SeverityToLevel

func SeverityToLevel(s string) (slog.Level, error)

Returns severity level based on string.

Types

type Logger

type Logger interface {
	// DebugContext is for reporting additional information about internal operations.
	DebugContext(ctx context.Context, format string, args ...interface{})
	// InfoContext is for reporting informational messages.
	InfoContext(ctx context.Context, format string, args ...interface{})
	// WarnContext is for reporting warning messages.
	WarnContext(ctx context.Context, format string, args ...interface{})
	// ErrorContext is for reporting errors.
	ErrorContext(ctx context.Context, format string, args ...interface{})
}

Logger is the interface used throughout the project for logging.

func NewLogger added in v0.27.0

func NewLogger(format, level string, out, err io.Writer) (Logger, error)

NewLogger creates a new logger based on the provided format and level.

func NewStdLogger

func NewStdLogger(outW, errW io.Writer, logLevel string) (Logger, error)

NewStdLogger create a Logger that uses out and err for informational and error messages.

func NewStructuredLogger

func NewStructuredLogger(outW, errW io.Writer, logLevel string) (Logger, error)

NewStructuredLogger create a Logger that logs messages using JSON.

type StdLogger

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

StdLogger is the standard logger

func (*StdLogger) DebugContext added in v0.0.5

func (sl *StdLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...interface{})

DebugContext logs debug messages

func (*StdLogger) ErrorContext added in v0.0.5

func (sl *StdLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...interface{})

ErrorContext logs error messages

func (*StdLogger) InfoContext added in v0.0.5

func (sl *StdLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...interface{})

InfoContext logs debug messages

func (*StdLogger) WarnContext added in v0.0.5

func (sl *StdLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...interface{})

WarnContext logs warning messages

type StructuredLogger

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

func (*StructuredLogger) DebugContext added in v0.0.5

func (sl *StructuredLogger) DebugContext(ctx context.Context, msg string, keysAndValues ...interface{})

DebugContext logs debug messages

func (*StructuredLogger) ErrorContext added in v0.0.5

func (sl *StructuredLogger) ErrorContext(ctx context.Context, msg string, keysAndValues ...interface{})

ErrorContext logs error messages

func (*StructuredLogger) InfoContext added in v0.0.5

func (sl *StructuredLogger) InfoContext(ctx context.Context, msg string, keysAndValues ...interface{})

InfoContext logs info messages

func (*StructuredLogger) WarnContext added in v0.0.5

func (sl *StructuredLogger) WarnContext(ctx context.Context, msg string, keysAndValues ...interface{})

WarnContext logs warning messages

type ValueTextHandler

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

ValueTextHandler is a [Handler] that writes Records to an io.Writer with values separated by spaces.

func NewValueTextHandler

func NewValueTextHandler(out io.Writer, opts *slog.HandlerOptions) *ValueTextHandler

NewValueTextHandler creates a ValueTextHandler that writes to out, using the given options.

func (*ValueTextHandler) Enabled

func (h *ValueTextHandler) Enabled(ctx context.Context, level slog.Level) bool

func (*ValueTextHandler) Handle

func (h *ValueTextHandler) Handle(ctx context.Context, r slog.Record) error

Handle formats its argument [Record] as a single line of space-separated values. Example output format: 2024-11-12T15:08:11.451377-08:00 INFO "Initialized 0 sources.\n"

func (*ValueTextHandler) WithAttrs

func (h *ValueTextHandler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*ValueTextHandler) WithGroup

func (h *ValueTextHandler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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