logging

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2020 License: MIT Imports: 9 Imported by: 0

README

Stackdriver Logging for Go Google Cloud Functions

GoDoc

Documentation

Overview

Package logging implements improved logging for Google Cloud Functions.

Improvements include support for log levels as well as execution ids.

Usage:

func HelloWorld(w http.ResponseWriter, r *http.Request) {
    ctx := logging.ForRequest(r)
    // ...
    logging.Info(ctx).Println("Hello logs")
    logging.Error(ctx).Println("Hello logs")
}

When deploying your function, you need to set the following environment variables:

GOOGLE_CLOUD_PROJECT:  The current GCP project ID.
FUNCTION_NAME:         The name of the function resource.
FUNCTION_REGION:       The function region (example: us-central1).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flush

func Flush() error

Flush all loggers. Blocking.

func ForRequest

func ForRequest(r *http.Request) context.Context

ForRequest creates a logging Context for the Request.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

A Logger represents an contextualized logging object that pushes entries to Stackdriver.

func Alert

func Alert(ctx context.Context) Logger

Alert gets a Logger for when a person must take an action immediately.

func Critical

func Critical(ctx context.Context) Logger

Critical gets a Logger for events that cause more severe problems or brief outages.

func Debug

func Debug(ctx context.Context) Logger

Debug gets a Logger for debug or trace information.

func Default

func Default(ctx context.Context) Logger

Default gets a Logger with no assigned severity level.

func Emergency

func Emergency(ctx context.Context) Logger

Emergency gets a Logger for when one or more systems are unusable.

func Error

func Error(ctx context.Context) Logger

Error gets a Logger for events that are likely to cause problems.

func Info

func Info(ctx context.Context) Logger

Info gets a Logger for routine information, such as ongoing status or performance.

func Notice

func Notice(ctx context.Context) Logger

Notice gets a Logger for normal but significant events, such as start up, shut down, or configuration.

func Warning

func Warning(ctx context.Context) Logger

Warning gets a Logger for events that might cause problems.

func (Logger) Print

func (l Logger) Print(v ...interface{})

Print logs using the default formats for its operands. Spaces are added between operands when neither is a string.

func (Logger) Printf

func (l Logger) Printf(format string, v ...interface{})

Printf logs according to a format specifier.

func (Logger) Println

func (l Logger) Println(v ...interface{})

Println logs using the default formats for its operands. Spaces are always added between operands and a newline is appended.

Jump to

Keyboard shortcuts

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