GCP - Cloud FunctionsHow can you modify an HTTP triggered function to log the request method and path before processing it?Adef func(request): logger.info(request.method + request.path) return ('Done', 200)Bdef func(request): log(request.method, request.path) return ('Done', 200)Cdef func(request): print(f'Method: {request.method}, Path: {request.path}') return ('Done', 200)Ddef func(request): return ('Done', 200)Check Answer
Step-by-Step SolutionSolution:Step 1: Identify valid logging methodUsing print is a simple way to log in Cloud Functions.Step 2: Confirm access to method and pathrequest.method and request.path provide HTTP method and URL path.Final Answer:Using print with f-string to log method and path -> Option CQuick Check:Print request.method and request.path logs info [OK]Quick Trick: Use print(f'...') to log request details in Cloud Functions [OK]Common Mistakes:Using undefined log or logger without importConcatenating strings without spacesNot logging request details at all
Master "Cloud Functions" in GCP9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More GCP Quizzes Cloud Firestore and Bigtable - Firestore queries and indexes - Quiz 7medium Cloud Functions - Cloud Functions generations (1st vs 2nd) - Quiz 2easy Cloud Functions - Why serverless functions matter - Quiz 9hard Cloud Load Balancing - Health checks configuration - Quiz 3easy Cloud Monitoring and Logging - Log Explorer and queries - Quiz 11easy Cloud Monitoring and Logging - Log Explorer and queries - Quiz 2easy Cloud Pub/Sub - Topics and subscriptions - Quiz 1easy Cloud Pub/Sub - Pull vs push subscriptions - Quiz 13medium Cloud SQL and Databases - Why managed databases matter - Quiz 2easy Cloud SQL and Databases - Read replicas - Quiz 10hard