File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,19 @@ def logger_usage(client, to_delete):
133133 ) # API call
134134 # [END logger_log_struct]
135135
136+ # [START logger_log_resource_text]
137+ from google .cloud .logging .resource import Resource
138+ res = Resource (type = "generic_node" ,
139+ labels = {
140+ 'location' : 'us-central1-a' ,
141+ 'namespace' : 'default' ,
142+ 'node_id' : '10.10.10.1'
143+ })
144+ logger .log_struct (
145+ {"message" : "My first entry" , "weather" : "partly cloudy" }, resource = res
146+ )
147+ # [END logger_log_resource_text]
148+
136149 # [START logger_list_entries]
137150 from google .cloud .logging import DESCENDING
138151
Original file line number Diff line number Diff line change @@ -24,6 +24,17 @@ Write a dictionary entry to the logger.
2424 :end-before: [END logger_log_struct]
2525 :dedent: 4
2626
27+ Write a simple text entry and resource to the logger.
28+
29+ Supported Resource values are listed at `Monitored Resource Types `_
30+
31+ .. _Monitored Resource Types : https://cloud.google.com/logging/docs/api/v2/resource-list
32+
33+
34+ .. literalinclude :: snippets.py
35+ :start-after: [START logger_log_resource_text]
36+ :end-before: [END logger_log_resource_text]
37+ :dedent: 4
2738
2839Retrieving log entries
2940----------------------
You can’t perform that action at this time.
0 commit comments