Skip to content

Commit

Permalink
Update samples to support latest Google Cloud Python [(googleapis#656)](
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Wayne Parrott authored and busunkim96 committed Oct 30, 2020
1 parent 4f1391b commit 61f1eca
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 18 deletions.
8 changes: 1 addition & 7 deletions samples/snippets/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ def list_sinks():
"""Lists all sinks."""
logging_client = logging.Client()

sinks = []
token = None
while True:
new_sinks, token = logging_client.list_sinks(page_token=token)
sinks.extend(new_sinks)
if token is None:
break
sinks = list(logging_client.list_sinks())

if not sinks:
print('No sinks.')
Expand Down
2 changes: 1 addition & 1 deletion samples/snippets/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google-cloud-logging==0.20.0
google-cloud-logging==0.21.0
11 changes: 1 addition & 10 deletions samples/snippets/snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,7 @@ def list_entries(logger_name):

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

entries = []
page_token = None

while True:
new_entries, page_token = logger.list_entries(page_token=page_token)
entries.extend(new_entries)
if not page_token:
break

for entry in entries:
for entry in logger.list_entries():
timestamp = entry.timestamp.isoformat()
print('* {}: {}'.format
(timestamp, entry.payload))
Expand Down

0 comments on commit 61f1eca

Please sign in to comment.