// Package log contains examples for handling Cloud Functions logs.packagelogimport("context""log")// PubSubMessage is the payload of a Pub/Sub event.// See the documentation for more details:// https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessagetypePubSubMessagestruct{Data[]byte`json:"data"`}// ProcessLogEntry processes a Pub/Sub message from Cloud Logging.funcProcessLogEntry(ctxcontext.Context,mPubSubMessage)error{log.Printf("Log entry data: %s",string(m.Data))returnnil}
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-09 (世界標準時間)。"],[[["Cloud Audit Logs can be filtered and forwarded to Pub/Sub topics using sinks, allowing you to create custom events from various Google Cloud services."],["Cloud Run functions can be triggered by notifications from Pub/Sub topics, which receive forwarded Cloud Audit Logs."],["Functions triggered by Cloud log entries receive a `PubsubMessage` object, where the `data` parameter, when decoded, provides the log entry as a JSON string."],["Sample code is provided for Node.js, Python, Go, and Java to demonstrate how to process and respond to exported Cloud logs within a Pub/Sub-triggered function."],["To deploy a function, you can use the `gcloud functions deploy` command and the `--runtime` flag to specify the required runtime."]]],[]]