Skip to content

Latest commit

 

History

History
47 lines (30 loc) · 958 Bytes

README.md

File metadata and controls

47 lines (30 loc) · 958 Bytes

Google CloudFunctions support package

Logging

example for trigger http function:

package function

import (
	"fmt"
	"net/http"

	"github.com/groove-x/cloudfunctions/log"
)

func ExampleLogging(w http.ResponseWriter, r *http.Request) {
	log.WithRequest(r)
	defer log.Flush()

	log.Debug("debug")
	log.Info("info")
	log.Warn("warn")
	log.Error("error")

	logger := log.WithField("key1", 1)
	logger.Info("structured log")

	log.WithFields(map[string]interface{}{"foo": 1, "bar": 2}).Debug("structured debug log")

	fmt.Fprintln(w, "hello")
}

deploy:

$ gcloud functions deploy function-1 --runtime=go113 --region=asia-northeast1 --timeout=60s --trigger-http --entry-point=ExampleLogging

requirement for logging