gcphandler

package
v0.0.0-...-285e13b Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package gcphandler implements a slog.Handler that works with the Google Cloud Platform's logging service. It always writes to stderr, so it is most suitable for programs that run on a managed service that treats JSON lines written to stderr as logs, like Cloud Run and AppEngine.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(level slog.Leveler) slog.Handler

New creates a new slog.Handler for GCP logging. It follows GCP's logging specification by modifying slog defaults:

  • It replaces the key "msg" with "message".
  • It replaces the key "level" with "severity".
  • It replaces the key "traceID" with "logging.googleapis.com/trace.".
  • It replaces the value for the "time" key with an RFC3339-formatted string.

It also appends some attributes to the message, because the GCP log viewer requires two clicks to get from the main log view to the attributes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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