Skip to content

Commit 984aefa

Browse files
author
Jon Wayne Parrott
authored
Update samples to support latest Google Cloud Python [(googleapis#656)](GoogleCloudPlatform/python-docs-samples#656)
1 parent c1d1f0d commit 984aefa

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

samples/snippets/export.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@ def list_sinks():
2323
"""Lists all sinks."""
2424
logging_client = logging.Client()
2525

26-
sinks = []
27-
token = None
28-
while True:
29-
new_sinks, token = logging_client.list_sinks(page_token=token)
30-
sinks.extend(new_sinks)
31-
if token is None:
32-
break
26+
sinks = list(logging_client.list_sinks())
3327

3428
if not sinks:
3529
print('No sinks.')

samples/snippets/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-logging==0.20.0
1+
google-cloud-logging==0.21.0

samples/snippets/snippets.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,7 @@ def list_entries(logger_name):
5656

5757
print('Listing entries for logger {}:'.format(logger.name))
5858

59-
entries = []
60-
page_token = None
61-
62-
while True:
63-
new_entries, page_token = logger.list_entries(page_token=page_token)
64-
entries.extend(new_entries)
65-
if not page_token:
66-
break
67-
68-
for entry in entries:
59+
for entry in logger.list_entries():
6960
timestamp = entry.timestamp.isoformat()
7061
print('* {}: {}'.format
7162
(timestamp, entry.payload))

0 commit comments

Comments
 (0)