Skip to content
Permalink
Browse files
fix: remove noisy logs (#290)
  • Loading branch information
daniel-sanche committed May 12, 2021
1 parent 3324656 commit bdf827358de5935f736ecd73ab10b2d861daf690
Showing with 24 additions and 5 deletions.
  1. +9 −2 google/cloud/logging_v2/handlers/handlers.py
  2. +1 −1 tests/environment
  3. +14 −2 tests/unit/test_client.py
@@ -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")

@@ -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())
@@ -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)
@@ -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)

0 comments on commit bdf8273

Please sign in to comment.