| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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 |
| .. code-block:: python | ||
|
|
||
| >>> import logging | ||
| >>> import google.cloud.logging # Don't conflict with standard logging |
| >>> client = google.cloud.logging.Client() | ||
| >>> handler = CloudLoggingHandler(client) | ||
| >>> cloud_logger = logging.getLogger('cloudLogger') | ||
| >>> cloud_logger.setLevel(logging.INFO) # defaults to WARN |
|
|
||
| .. code-block:: python | ||
|
|
||
| >>> handler = CloudLoggingHandler(client, name="mycustomlog") |
| 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 |
| FILTER = 'textPayload:robot' | ||
|
|
||
| # [START sink_bigquery_create] | ||
| DESTINATION = 'bigquery.googleapis.com%s' % (dataset.path) |
| UPDATED_FILTER = 'textPayload:robot' | ||
|
|
||
| # [START sink_pubsub_create] | ||
| DESTINATION = 'pubsub.googleapis.com/%s' % (topic.full_name) |
| def _find_examples(): | ||
| funcs = [obj for obj in globals().values() | ||
| if getattr(obj, '_snippet', False)] | ||
| for func in sorted(funcs, key=_line_no): |
|
|
||
|
|
||
| def _line_no(func): | ||
| code = getattr(func, '__code__', None) or getattr(func, 'func_code') |
| except AssertionError as e: | ||
| print(' FAIL: %s' % (e,)) | ||
| except Exception as e: # pylint: disable=broad-except | ||
| print(' ERROR: %r' % (e,)) |
Convert logging doctest examples to testable snippets.
| Back | FazBrowse Home | New Git URL |
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.