Skip to content

Issue with logging and google-auth #3931

@tcroiset

Description

@tcroiset

The following code:

import google.cloud.logging
import logging

from google.cloud.logging.handlers import CloudLoggingHandler

client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client)
cloud_logger = logging.getLogger()
cloud_logger.setLevel(logging.INFO)
cloud_logger.addHandler(handler)
cloud_logger.addHandler(logging.StreamHandler())
cloud_logger.info('hello')

works fine with google-cloud-logging==1.1.0 but fails with newer versions (1.2.0 or 1.3.0) :

Failed to submit 1 logs.
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/handlers/transports/background_thread.py", line 99, in _safely_commit_batch
    batch.commit()
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/logger.py", line 549, in commit
    client.logging_api.write_entries(entries, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/logging/_http.py", line 163, in write_entries
    self.api_request(method='POST', path='/entries:write', data=data)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 290, in api_request
    headers=headers, target_object=_target_object)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 183, in _make_request
    return self._do_request(method, url, headers, data, target_object)
  File "/usr/local/lib/python2.7/dist-packages/google/cloud/_http.py", line 212, in _do_request
    url=url, method=method, headers=headers, data=data)
  File "/usr/local/lib/python2.7/dist-packages/google/auth/transport/requests.py", line 175, in request
    self.credentials.before_request(
AttributeError: 'AuthorizedSession' object has no attribute 'credentials'

Metadata

Metadata

Labels

api: loggingIssues related to the Cloud Logging API.authtype: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions