gcl

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package gcl provides a log/slog.Handler for Google Cloud Logging.

Index

Constants

View Source
const (
	FieldError          = "error"
	FieldRequest        = "request"
	FieldLatency        = "latency"
	FieldResponseSize   = "response_size"
	FieldRequestSize    = "request_size"
	FieldResponseStatus = "response_status"
	FieldRemoteIP       = "remote_ip"
)

Common log fields.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

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

Handler is a log/slog.Handler for GCP logging.

func New

func New(ctx context.Context, project, logID string, level slog.Leveler, clientOpts ...option.ClientOption) (*Handler, error)

New returns a new GCP logging handler.

func (*Handler) Close

func (h *Handler) Close() error

Close flushes any outstanding logs, and closes the client connection.

func (*Handler) Enabled

func (h *Handler) Enabled(_ context.Context, level slog.Level) bool

Enabled returns true if level is at least to the configured minimum level.

func (*Handler) Flush

func (h *Handler) Flush() error

Flush blocks until any outstanding logs have been flushed.

func (*Handler) Handle

func (h *Handler) Handle(_ context.Context, r slog.Record) error

Handle logs r to Google Cloud Logging.

func (*Handler) Ping

func (h *Handler) Ping(ctx context.Context) error

Ping creates a test log to ping the connection.

func (*Handler) WithAttrs

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

WithAttrs returns a clone of h, with attrs appended.

func (*Handler) WithGroup

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

WithGroup returns a clone of h, with the named group added.

Jump to

Keyboard shortcuts

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