Uh oh!
There was an error while loading. Please reload this page.
Convert logging doctest examples to testable snippets. - #2675
Conversation
Move usage docs for integration with Python stdlib 'logging' module into a separate file, sorted in front of the relevant API docs.
| It's possible to tie the Python :mod:`logging` module directly into Google Cloud Logging. To use it, | ||
| create a :class:`CloudLoggingHandler <google.cloud.logging.CloudLoggingHandler>` instance from your |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| .. code-block:: python | ||
| >>> import logging | ||
| >>> import google.cloud.logging # Don't conflict with standard logging |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| >>> client = google.cloud.logging.Client() | ||
| >>> handler = CloudLoggingHandler(client) | ||
| >>> cloud_logger = logging.getLogger('cloudLogger') | ||
| >>> cloud_logger.setLevel(logging.INFO) # defaults to WARN |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| .. code-block:: python | ||
| >>> handler = CloudLoggingHandler(client, name="mycustomlog") |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| options, see the transports section. | ||
| All logs will go to a single custom log, which defaults to "python". The name of the Python | ||
| logger will be included in the structured log entry under the "python_logger" field. You can |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| FILTER = 'textPayload:robot' | ||
| # [START sink_bigquery_create] | ||
| DESTINATION = 'bigquery.googleapis.com%s' % (dataset.path) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| UPDATED_FILTER = 'textPayload:robot' | ||
| # [START sink_pubsub_create] | ||
| DESTINATION = 'pubsub.googleapis.com/%s' % (topic.full_name) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def _find_examples(): | ||
| funcs = [obj for obj in globals().values() | ||
| if getattr(obj, '_snippet', False)] | ||
| for func in sorted(funcs, key=_line_no): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| def _line_no(func): | ||
| code = getattr(func, '__code__', None) or getattr(func, 'func_code') |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
| except AssertionError as e: | ||
| print(' FAIL: %s' % (e,)) | ||
| except Exception as e: # pylint: disable=broad-except | ||
| print(' ERROR: %r' % (e,)) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Convert logging doctest examples to testable snippets.
Move usage docs for integration with Python stdlib 'logging' module into a separate file, sorted in front of the relevant API docs.
Reworks #2556 after other merges (iterators, doctest removal) made fixing that PRs branch too painful.