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 ¶
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.
Click to show internal directories.
Click to hide internal directories.