Skip to content

Cloud Logging client is borked #11

Description

@DazWilkin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions