From 1ae34788aa34411441acc78d62881b374fa7bd61 Mon Sep 17 00:00:00 2001 From: mnito Date: Thu, 27 Jan 2022 19:12:43 -0500 Subject: [PATCH 1/6] bpo-46557: Log captured warnings without format string For systems that aggregate logs like Sentry, the use of a format string causes all warnings to be grouped under the same issue. --- Lib/logging/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index e49e0d02a80cf0e..121187f06ec8ea7 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -2246,7 +2246,7 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): logger = getLogger("py.warnings") if not logger.handlers: logger.addHandler(NullHandler()) - logger.warning("%s", s) + logger.warning(str(s)) def captureWarnings(capture): """ From 0f82fff0c2e049037662ebbbea3313de320a98e4 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Fri, 28 Jan 2022 01:23:26 +0000 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst diff --git a/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst new file mode 100644 index 000000000000000..677fa1f16d1d94f --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst @@ -0,0 +1 @@ +Captured warnings from the warnings module are now logged without a format string to prevent systems that group logs by the format string from grouping all warnings together \ No newline at end of file From f777c460de5374b90ab144874ed2f97c7e29afc1 Mon Sep 17 00:00:00 2001 From: mnito Date: Thu, 27 Jan 2022 21:18:23 -0500 Subject: [PATCH 3/6] Add period after blurb sentence --- .../next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst index 677fa1f16d1d94f..5221911de439cd4 100644 --- a/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst +++ b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst @@ -1 +1 @@ -Captured warnings from the warnings module are now logged without a format string to prevent systems that group logs by the format string from grouping all warnings together \ No newline at end of file +Captured warnings from the warnings module are now logged without a format string to prevent systems that group logs by the format string from grouping all warnings together. From 738289224a48de7327c55f11b47d8189d02b979d Mon Sep 17 00:00:00 2001 From: mnito Date: Thu, 27 Jan 2022 21:33:18 -0500 Subject: [PATCH 4/6] Refine blurb --- .../next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst index 5221911de439cd4..dd7d3f3d6c51ffd 100644 --- a/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst +++ b/Misc/NEWS.d/next/Library/2022-01-28-01-23-25.bpo-46557.XSbhyQ.rst @@ -1 +1 @@ -Captured warnings from the warnings module are now logged without a format string to prevent systems that group logs by the format string from grouping all warnings together. +Warnings captured by the logging module are now logged without a format string to prevent systems that group logs by the msg argument from grouping captured warnings together. From eb9348369949ad6cdd19f46eb5f7abb6635ad442 Mon Sep 17 00:00:00 2001 From: mnito Date: Fri, 28 Jan 2022 18:09:02 -0500 Subject: [PATCH 5/6] Add clarifying comment --- Lib/logging/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 121187f06ec8ea7..8c5938de5d297b5 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -2246,6 +2246,8 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): logger = getLogger("py.warnings") if not logger.handlers: logger.addHandler(NullHandler()) + # Log str(s) directly instead of with logger.warning("%s", s) + # since some log aggregation tools group logs by the msg arg logger.warning(str(s)) def captureWarnings(capture): From 84869597fbd2da337d2ced7e215f9e4fc259da72 Mon Sep 17 00:00:00 2001 From: mnito Date: Sat, 29 Jan 2022 08:02:52 -0500 Subject: [PATCH 6/6] Reference bpo issue number in comment --- Lib/logging/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py index 8c5938de5d297b5..160b1afcee0f9e8 100644 --- a/Lib/logging/__init__.py +++ b/Lib/logging/__init__.py @@ -2246,7 +2246,7 @@ def _showwarning(message, category, filename, lineno, file=None, line=None): logger = getLogger("py.warnings") if not logger.handlers: logger.addHandler(NullHandler()) - # Log str(s) directly instead of with logger.warning("%s", s) + # bpo-46557: Log str(s) as msg instead of logger.warning("%s", s) # since some log aggregation tools group logs by the msg arg logger.warning(str(s))