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 ¶
- func Flush() error
- func ForRequest(r *http.Request) context.Context
- type Logger
- func Alert(ctx context.Context) Logger
- func Critical(ctx context.Context) Logger
- func Debug(ctx context.Context) Logger
- func Default(ctx context.Context) Logger
- func Emergency(ctx context.Context) Logger
- func Error(ctx context.Context) Logger
- func Info(ctx context.Context) Logger
- func Notice(ctx context.Context) Logger
- func Warning(ctx context.Context) Logger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
A Logger represents an contextualized logging object that pushes entries to Stackdriver.
func Notice ¶
Notice gets a Logger for normal but significant events, such as start up, shut down, or configuration.
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.
Click to show internal directories.
Click to hide internal directories.