Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud Logging client is borked #11

Open
DazWilkin opened this issue Mar 3, 2021 · 0 comments
Open

Cloud Logging client is borked #11

DazWilkin opened this issue Mar 3, 2021 · 0 comments

Comments

@DazWilkin
Copy link

DazWilkin commented Mar 3, 2021

Per: https://github.com/salrashid123/gcpsamples#iterators

See: googleapis/python-logging#203

I think you'd want (see # comments):

import os
from google.cloud import logging

from google.cloud.logging import ASCENDING
from google.cloud.logging import DESCENDING

FILTER = 'resource.type="gae_app" AND logName="projects/mineral-minutia-820/logs/appengine.googleapis.com%2Frequest_log" AND protoPayload.resource="/"'

# Disable gRPC
client = logging.Client(_use_grpc=0)

# Ensures this is an `HTTPIterator` rather than a (gRPC) `generator`
iterator = client.list_entries(filter_=FILTER, order_by=DESCENDING)
for page in iterator.pages:
  print('    Page number: %d' % (iterator.page_number,))
  print('  Items in page: %d' % (page.num_items,))
  print('Items remaining: %d' % (page.remaining,))
  print('Next page token: %s' % (iterator.next_page_token,))  
  print('----------------------------')
  for entry in page:
      print(entry.timestamp)

You may also set GOOGLE_CLOUD_DISABLE_GRPC={{anything}} instead of logging.Client(_use_grpc=0)

NOTE You're not using pp so I removed references to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant