log

package
Version: v0.0.0-...-8893da0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package log supports structured and unstructured logging with levels.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(ctx context.Context, arg any)

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

func Debugf

func Debugf(ctx context.Context, format string, args ...any)

Debugf logs a formatted string at the Debug level.

func Error

func Error(ctx context.Context, arg any)

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

func Errorf

func Errorf(ctx context.Context, format string, args ...any)

Errorf logs a formatted string at the Error level.

func Fatal

func Fatal(ctx context.Context, arg any)

Fatal logs arg, which can be a string or a struct, at the Critical level followed by exiting the program.

func Fatalf

func Fatalf(ctx context.Context, format string, args ...any)

Fatalf logs formatted string at the Critical level followed by exiting the program.

func Info

func Info(ctx context.Context, arg any)

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

func Infof

func Infof(ctx context.Context, format string, args ...any)

Infof logs a formatted string at the Info level.

func NewContextWithLabel

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

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

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

func SetLevel

func SetLevel(v string)

Set the log level

func UseStackdriver

func UseStackdriver(ctx context.Context, logName, projectID string, opts []logging.LoggerOption) (_ *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.

func Warning

func Warning(ctx context.Context, arg any)

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

func Warningf

func Warningf(ctx context.Context, format string, args ...any)

Warningf logs a formatted string at the Warning level.

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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