Skip to content

Commit

Permalink
fix: remove noisy logs (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed May 12, 2021
1 parent 3324656 commit bdf8273
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
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

0 comments on commit bdf8273

Please sign in to comment.