Skip to content

groove-x/cloudfunctions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Google Cloud Functions support package

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages