log

package
v0.0.0-...-5f32e1b Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package log implements logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, msg string, args ...any)

func Debugf

func Debugf(ctx context.Context, format string, args ...any)

func Error

func Error(ctx context.Context, msg string, err error, args ...any)

func Errorf

func Errorf(ctx context.Context, err error, format string, args ...any)

func FromContext

func FromContext(ctx context.Context) *slog.Logger

FromContext retrieves a logger from the context. If there is none, it returns the default logger.

func Info

func Info(ctx context.Context, msg string, args ...any)

func Infof

func Infof(ctx context.Context, format string, args ...any)

func Logf

func Logf(ctx context.Context, level slog.Level, format string, args ...any)

func NewContext

func NewContext(ctx context.Context, l *slog.Logger) context.Context

NewContext adds the logger to the context.

func NewGoogleCloudHandler

func NewGoogleCloudHandler() slog.Handler

NewGoogleCloudHandler returns a Handler that outputs JSON for the Google Cloud logging service. See https://cloud.google.com/logging/docs/agent/logging/configuration#special-fields for treatment of special fields.

func Warn

func Warn(ctx context.Context, msg string, args ...any)

func Warnf

func Warnf(ctx context.Context, format string, args ...any)

Types

type LineHandler

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

LineHandler is a slog.Handler that writes log events one per line in an easy-to-read format:

time level message label1=value1 label2=value2 ...

func NewLineHandler

func NewLineHandler(w io.Writer) *LineHandler

func (*LineHandler) Enabled

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

func (*LineHandler) Handle

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

func (*LineHandler) WithAttrs

func (h *LineHandler) WithAttrs(as []slog.Attr) slog.Handler

func (*LineHandler) WithGroup

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

Jump to

Keyboard shortcuts

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