Created stackdriver Log sink with cloud pub/sub topic and this topic has been subscribed with below cloud function to print the log message but it throws an error when testing the function. Before testing the function , produced that error to get the logs in stackdriver logging.
import base64
def hello_pubsub(event, context):
"""Triggered from a message on a Cloud Pub/Sub topic.
Args:
event (dict): Event payload.
context (google.cloud.functions.Context): Metadata for the event.
"""
pubsub_message = base64.b64decode(event['data']).decode('utf-8')
print(pubsub_message)
The error message I get:
Error: function terminated. Recommended action: inspect logs for termination reason. Details:
'data'
But I couldn't find any logs. It only says that the function finished with status 'crash'.
I assume the problem is with pulling / pushing the log to function. Any help would be appreciated .