8000 fix: remove noisy logs (#290) · googleapis/python-logging@bdf8273 · GitHub
[go: up one dir, main page]

Skip to content

Commit bdf8273

Browse files
committed
fix: remove noisy logs (#290)
1 parent 3324656 commit bdf8273

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

google/cloud/logging_v2/handlers/handlers.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,14 @@
2424

2525
DEFAULT_LOGGER_NAME = "python"
2626

27-
EXCLUDED_LOGGER_DEFAULTS = ("google.cloud", "google.auth", "google_auth_httplib2")
27+
"""Exclude internal logs from propagating through handlers"""
28+
EXCLUDED_LOGGER_DEFAULTS = (
29+
"google.cloud",
30+
"google.auth",
31+
"google_auth_httplib2",
32+
"google.api_core.bidi",
33+
"werkzeug",
34+
)
2835

2936
_CLEAR_HANDLER_RESOURCE_TYPES = ("gae_app", "cloud_function")
3037

@@ -221,6 +228,6 @@ def setup_logging(
221228
logger.setLevel(log_level)
222229
logger.addHandler(handler)
223230
for logger_name in all_excluded_loggers:
231+
# prevent excluded loggers from propagating logs to handler
224232
logger = logging.getLogger(logger_name)
225233
logger.propagate = False
226-
logger.addHandler(logging.StreamHandler())

tests/environment

tests/unit/test_client.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -799,7 +799,13 @@ def test_setup_logging(self):
799799
handler.transport.worker.stop()
800800

801801
expected_kwargs = {
802-
"excluded_loggers": ("google.cloud", "google.auth", "google_auth_httplib2"),
802+
"excluded_loggers": (
803+
"google.cloud",
804+
"google.auth",
805+
"google_auth_httplib2",
806+
"google.api_core.bidi",
807+
"werkzeug",
808+
),
803809
"log_level": 20,
804810
}
805811
self.assertEqual(kwargs, expected_kwargs)
@@ -836,7 +842,13 @@ def test_setup_logging_w_extra_kwargs(self):
836842
handler.transport.worker.stop()
837843

838844
expected_kwargs = {
839-
"excluded_loggers": ("google.cloud", "google.auth", "google_auth_httplib2"),
845+
"excluded_loggers": (
846+
"google.cloud",
847+
"google.auth",
848+
"google_auth_httplib2",
849+
"google.api_core.bidi",
850+
"werkzeug",
851+
),
840852
"log_level": 20,
841853
}
842854
self.assertEqual(kwargs, expected_kwargs)

0 commit comments

Comments
 (0)
0