pkgsite: golang.org/x/pkgsite/internal/log Index | Files

package log

import "golang.org/x/pkgsite/internal/log"

Package log supports structured and unstructured logging with levels.

Index

Package Files

log.go

func Debug Uses

func Debug(ctx context.Context, arg interface{})

Debug logs arg, which can be a string or a struct, at the Debug level.

func Debugf Uses

func Debugf(ctx context.Context, format string, args ...interface{})

Debugf logs a formatted string at the Debug level.

func Error Uses

func Error(ctx context.Context, arg interface{})

Error logs arg, which can be a string or a struct, at the Error level.

func Errorf Uses

func Errorf(ctx context.Context, format string, args ...interface{})

Errorf logs a formatted string at the Error level.

func Fatal Uses

func Fatal(ctx context.Context, arg interface{})

Fatal is equivalent to Error followed by exiting the program.

func Fatalf Uses

func Fatalf(ctx context.Context, format string, args ...interface{})

Fatalf is equivalent to Errorf followed by exiting the program.

func Info Uses

func Info(ctx context.Context, arg interface{})

Info logs arg, which can be a string or a struct, at the Info level.

func Infof Uses

func Infof(ctx context.Context, format string, args ...interface{})

Infof logs a formatted string at the Info level.

func NewContextWithLabel Uses

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

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

func NewContextWithTraceID Uses

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

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

func UseStackdriver Uses

func UseStackdriver(ctx context.Context, cfg *config.Config, logName string) (_ *logging.Logger, err error)

UseStackdriver switches from the default stdlib logger to a Stackdriver logger. It assumes config.Init has been called. UseStackdriver 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" logger that will be used to log within a request. The two loggers are necessary to get request-scoped logs in Stackdriver. See https://cloud.google.com/appengine/docs/standard/go/writing-application-logs.

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

Package log imports 11 packages (graph) and is imported by 21 packages. Updated 2020-07-15. Refresh now. Tools for package owners.