@@ -16,6 +16,8 @@ Logging configuration.
1616.. _Cloud Logging API : https://cloud.google.com/logging
1717.. _Client Library Documentation : https://googleapis.dev/python/logging/latest
1818.. _Product Documentation : https://cloud.google.com/logging/docs
19+ .. _Setting Up Cloud Logging for Python : https://cloud.google.com/logging/docs/setup/python
20+ .. _Python's standard logging library : https://docs.python.org/2/library/logging.html
1921
2022Quick Start
2123-----------
@@ -74,60 +76,11 @@ Windows
7476 <your-env>\Scripts\activate
7577 <your-env>\Scripts\pip.exe install google-cloud-logging
7678
77- Using the API
78- -------------
79-
80- .. code :: python
81-
82- from google.cloud import logging_v2
83- client = logging_v2.LoggingServiceV2Client()
84-
85- resource = {
86- " type" : " global" ,
87- " labels" : {
88- " project_id" : " [PROJECT_ID]"
89- }
90- }
91-
92- """
93- Log entries can be either LogEntry or dict.
94- You can describe the same data in the following format:
95-
96- e = {
97- "log_name": "projects/[PROJECT_ID]/logs/test-logging",
98- "resource": resource,
99- "text_payload": "this is a log statement",
100- }
101- """
102- e = logging_v2.types.LogEntry(
103- log_name = " projects/[PROJECT_ID]/logs/test-logging" , # optional
104- resource = resource, # optional
105- text_payload = " this is a log statement" )
106-
107- entries = [e]
108- response = client.write_log_entries(entries)
109-
110- .. code :: python
111-
112- from google.cloud import logging
113- client = logging.Client()
114- logger = client.logger(' log_name' )
115- logger.log_text(' A simple entry' ) # API call
116-
117- Example of fetching entries:
118-
119- .. code :: python
120-
121- from google.cloud import logging
122- client = logging.Client()
123- logger = client.logger(' log_name' )
124- for entry in logger.list_entries():
125- print (entry.payload)
126-
12779 Next Steps
12880~~~~~~~~~~
12981
82+ - Read the `Setting Up Cloud Logging for Python `_ How-to Guide
83+ - Read the `Product documentation `_ to learn more about the product and see
84+ other How-to Guides.
13085- Read the `Client Library Documentation `_ for to see other available
13186 methods on the client.
132- - Read the `Product documentation `_ to learn more about the product and see
133- How-to Guides.
0 commit comments