Documentation ¶
Overview ¶
Package gcpcore is a custom zap.Core that formats Error logs for GCP Error Reporting
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloudRunServiceAndVersion ¶
CloudRunServiceAndVersion returns a service name and version based on the predefined env vars K_SERVICE & K_REVISION. Also works for GCP App Engine. See: https://cloud.google.com/run/docs/container-contract
func SourceLocation ¶
SourceLocation adds the correct Stackdriver "SourceLocation" field.
see: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#LogEntrySourceLocation
func WrapCore ¶
WrapCore returns a zap.Option that wraps the current core with the error reporting core. Any ErrorLogs will now be reported in a format that can ingest into GCP Error Reporting.
Example:
core := zap.Must(golog.NewLoggerConfigForGCP().Build( gcpcore.WrapCore(gcpcore.CloudRunServiceAndVersion()), )) logger := core.Sugar().Named("web_server")
Types ¶
This section is empty.