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

Fix untested logging snippet examples. #3219

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/logging-stdlib-usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can also exclude certain loggers:

.. code-block:: python

>>> setup_logging(handler, excluded_loggers=('werkzeug',)))
>>> setup_logging(handler, excluded_loggers=('werkzeug',))

This comment was marked as spam.

This comment was marked as spam.




Expand All @@ -68,4 +68,3 @@ The Python logging handler can use different transports. The default is

1. :class:`google.cloud.logging.handlers.SyncTransport` this handler does a direct API call on each
logging statement to write the entry.

5 changes: 3 additions & 2 deletions logging/google/cloud/logging/handlers/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CloudLoggingHandler(logging.StreamHandler):

.. code-block:: python

import logging
import google.cloud.logging
from google.cloud.logging.handlers import CloudLoggingHandler

Expand All @@ -62,7 +63,7 @@ class CloudLoggingHandler(logging.StreamHandler):
cloud_logger.setLevel(logging.INFO)
cloud_logger.addHandler(handler)

cloud.logger.error('bad news') # API call
cloud_logger.error('bad news') # API call

"""

Expand Down Expand Up @@ -117,7 +118,7 @@ def setup_logging(handler, excluded_loggers=EXCLUDED_LOGGER_DEFAULTS,

client = google.cloud.logging.Client()
handler = CloudLoggingHandler(client)
google.cloud.logging.setup_logging(handler)
google.cloud.logging.handlers.setup_logging(handler)

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

logging.getLogger().setLevel(logging.DEBUG)

logging.error('bad news') # API call
Expand Down