stackdriverlogger

package
v0.0.0-...-86cb477 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package log supports structured and unstructured logging with levels to GCP stackdriver.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, logName, projectID string, opts []logging.LoggerOption) (_ log.Logger, _ *logging.Logger, err error)

New creates a new Logger that logs to Stackdriver. It assumes config.Init has been called. New returns a "parent" *logging.Logger that should be used to log the start and end of a request. It also creates and remembers internally a "child" log.Logger that will be used to log within a request. The child logger should be passed to log.Use to forward the log package's logging calls to the child logger. The two loggers are necessary to get request-scoped logs in Stackdriver. See https://cloud.google.com/appengine/docs/standard/go/writing-application-logs.

New can only be called once. If it is called a second time, it returns an error.

func NewContextWithLabel

func NewContextWithLabel(ctx context.Context, key, value string) context.Context

NewContextWithLabel creates a new context from ctx that adds a label that will appear in the log entry.

func NewContextWithTraceID

func NewContextWithTraceID(ctx context.Context, traceID string) context.Context

NewContextWithTraceID creates a new context from ctx that adds the trace ID.

Types

This section is empty.

Jump to

Keyboard shortcuts

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