cloudslog

package
v0.79.1 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package cloudslog provides primitives for structured logging with the standard library log/slog package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(config LoggerConfig) slog.Handler

NewHandler creates a new slog.Handler with special-handling for Cloud Run.

func With added in v0.74.0

func With(parent context.Context, args ...any) context.Context

With appends log attributes to the current parent context. Arguments are converted to attributes as if by slog.Logger.Log.

Types

type LoggerConfig

type LoggerConfig struct {
	// Development indicates if the logger should output human-readable output for development.
	Development bool `default:"true" onGCE:"false"`
	// Level indicates which log level the logger should output at.
	Level slog.Level `default:"debug" onGCE:"info"`
	// ProtoMessageSizeLimit is the maximum size, in bytes, of requests and responses to log.
	// Messages large than the limit will be truncated.
	// Default value, 0, means that no messages will be truncated.
	ProtoMessageSizeLimit int `onGCE:"1024"`
}

LoggerConfig configures the application logger.

Jump to

Keyboard shortcuts

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