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: remove noisy logs #290

Merged
merged 6 commits into from May 11, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -61,3 +61,6 @@ system_tests/local_test_setup
# Make sure a generated file isn't accidentally committed.
pylintrc
pylintrc.test

# ignore owlbot
owl-bot-staging
11 changes: 9 additions & 2 deletions google/cloud/logging_v2/handlers/handlers.py
Expand Up @@ -24,7 +24,14 @@

DEFAULT_LOGGER_NAME = "python"

EXCLUDED_LOGGER_DEFAULTS = ("google.cloud", "google.auth", "google_auth_httplib2")
"""Exclude internal logs from propagating through handlers"""
EXCLUDED_LOGGER_DEFAULTS = (
"google.cloud",
"google.auth",
"google_auth_httplib2",
"google.api_core.bidi",
"werkzeug",
)

_CLEAR_HANDLER_RESOURCE_TYPES = ("gae_app", "cloud_function")

Expand Down Expand Up @@ -221,6 +228,6 @@ def setup_logging(
logger.setLevel(log_level)
logger.addHandler(handler)
for logger_name in all_excluded_loggers:
# prevent excluded loggers from propagating logs to handler
logger = logging.getLogger(logger_name)
logger.propagate = False
logger.addHandler(logging.StreamHandler())
2 changes: 1 addition & 1 deletion tests/environment
16 changes: 14 additions & 2 deletions tests/unit/test_client.py
Expand Up @@ -799,7 +799,13 @@ def test_setup_logging(self):
handler.transport.worker.stop()

expected_kwargs = {
"excluded_loggers": ("google.cloud", "google.auth", "google_auth_httplib2"),
"excluded_loggers": (
"google.cloud",
"google.auth",
"google_auth_httplib2",
"google.api_core.bidi",
"werkzeug",
),
"log_level": 20,
}
self.assertEqual(kwargs, expected_kwargs)
Expand Down Expand Up @@ -836,7 +842,13 @@ def test_setup_logging_w_extra_kwargs(self):
handler.transport.worker.stop()

expected_kwargs = {
"excluded_loggers": ("google.cloud", "google.auth", "google_auth_httplib2"),
"excluded_loggers": (
"google.cloud",
"google.auth",
"google_auth_httplib2",
"google.api_core.bidi",
"werkzeug",
),
"log_level": 20,
}
self.assertEqual(kwargs, expected_kwargs)
Expand Down