1818
1919# [END functions_log_stackdriver]
2020
21- # [START functions_log_retrieve]
22- import google .cloud .logging as cloud_logging
23- # [END functions_log_retrieve]
24-
2521
2622# [START functions_log_helloworld]
2723def hello_world (data , context ):
@@ -34,36 +30,6 @@ def hello_world(data, context):
3430# [END functions_log_helloworld]
3531
3632
37- # [START functions_log_retrieve]
38- cloud_client = cloud_logging .Client ()
39- log_name = 'cloudfunctions.googleapis.com%2Fcloud-functions'
40- cloud_logger = cloud_client .logger (log_name )
41-
42-
43- def get_log_entries (request ):
44- """
45- HTTP Cloud Function that displays log entries from Cloud Functions.
46- Args:
47- request (flask.Request): The request object.
48- Returns:
49- The response text, or any set of values that can be turned into a
50- Response object using `make_response`
51- <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>.
52- """
53- """"""
54-
55- all_entries = cloud_logger .list_entries (page_size = 10 )
56- entries = next (all_entries .pages )
57-
58- for entry in entries :
59- timestamp = entry .timestamp .isoformat ()
60- print ('* {}: {}' .format
61- (timestamp , entry .payload ))
62-
63- return 'Done!'
64- # [END functions_log_retrieve]
65-
66-
6733# [START functions_log_stackdriver]
6834def process_log_entry (data , context ):
6935 data_buffer = base64 .b64decode (data ['data' ])
0 commit comments