* [OE-core][PATCH] send-error-report: improve debugging
@ 2025-04-16 10:01 thomas.perrot
2025-04-18 11:27 ` Quentin Schulz
0 siblings, 1 reply; 3+ messages in thread
From: thomas.perrot @ 2025-04-16 10:01 UTC (permalink / raw)
To: openembedded-core; +Cc: thomas.petazzoni, Thomas Perrot
From: Thomas Perrot <thomas.perrot@bootlin.com>
- add a debug mode
- print the request and the response when an error occurs.
Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
---
scripts/send-error-report | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/scripts/send-error-report b/scripts/send-error-report
index cfbcaa52cbc3..cdc1dfc5613a 100755
--- a/scripts/send-error-report
+++ b/scripts/send-error-report
@@ -6,6 +6,7 @@
# Copyright (C) 2013 Intel Corporation
# Author: Andreea Proca <andreea.b.proca@intel.com>
# Author: Michael Wood <michael.g.wood@intel.com>
+# Author: Thomas Perrot <thomas.perrot@bootlin.com>
#
# SPDX-License-Identifier: GPL-2.0-only
#
@@ -22,7 +23,7 @@ scripts_lib_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'li
sys.path.insert(0, scripts_lib_path)
import argparse_oe
-version = "0.3"
+version = "0.4"
log = logging.getLogger("send-error-report")
logging.basicConfig(format='%(levelname)s: %(message)s')
@@ -140,13 +141,25 @@ def send_data(data, args):
url = args.protocol+args.server+"/ClientPost/"
req = urllib.request.Request(url, data=data, headers=headers)
+
+ if args.debug:
+ log.debug(f"Request URL: {url}")
+ log.debug(f"Request Headers: {headers}")
+ log.debug(f"Request Data: {data.decode('utf-8')}")
+
try:
response = urllib.request.urlopen(req)
except urllib.error.HTTPError as e:
- logging.error(str(e))
+ log.error(f"HTTP Error {e.code}: {e.reason}")
+ log.debug(f"Response Content: {e.read().decode('utf-8')}")
sys.exit(1)
- print(response.read().decode('utf-8'))
+ if args.debug:
+ log.debug(f"Response Status: {response.status}")
+ log.debug(f"Response Headers: {response.getheaders()}")
+ log.debug(f"Response Content: {response.read().decode('utf-8')}")
+ else:
+ print(response.read().decode('utf-8'))
if __name__ == '__main__':
@@ -195,13 +208,20 @@ if __name__ == '__main__':
dest="protocol",
action="store_const", const="http://", default="https://")
-
+ arg_parse.add_argument("-d",
+ "--debug",
+ help="Enable debug mode to print request/response details",
+ action="store_true")
args = arg_parse.parse_args()
if (args.json == False):
print("Preparing to send errors to: "+args.server)
+ # Enable debugging if requested
+ if args.debug:
+ log.setLevel(logging.DEBUG)
+
data = prepare_data(args)
send_data(data, args)
--
2.49.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [OE-core][PATCH] send-error-report: improve debugging
2025-04-16 10:01 [OE-core][PATCH] send-error-report: improve debugging thomas.perrot
@ 2025-04-18 11:27 ` Quentin Schulz
2025-04-18 13:03 ` Thomas Perrot
0 siblings, 1 reply; 3+ messages in thread
From: Quentin Schulz @ 2025-04-18 11:27 UTC (permalink / raw)
To: thomas.perrot, openembedded-core; +Cc: thomas.petazzoni
Hi Thomas,
On 4/16/25 12:01 PM, Thomas Perrot via lists.openembedded.org wrote:
> From: Thomas Perrot <thomas.perrot@bootlin.com>
>
> - add a debug mode
> - print the request and the response when an error occurs.
>
> Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
> ---
> scripts/send-error-report | 28 ++++++++++++++++++++++++----
> 1 file changed, 24 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/send-error-report b/scripts/send-error-report
> index cfbcaa52cbc3..cdc1dfc5613a 100755
> --- a/scripts/send-error-report
> +++ b/scripts/send-error-report
> @@ -6,6 +6,7 @@
> # Copyright (C) 2013 Intel Corporation
> # Author: Andreea Proca <andreea.b.proca@intel.com>
> # Author: Michael Wood <michael.g.wood@intel.com>
> +# Author: Thomas Perrot <thomas.perrot@bootlin.com>
> #
> # SPDX-License-Identifier: GPL-2.0-only
> #
> @@ -22,7 +23,7 @@ scripts_lib_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'li
> sys.path.insert(0, scripts_lib_path)
> import argparse_oe
>
> -version = "0.3"
> +version = "0.4"
>
> log = logging.getLogger("send-error-report")
> logging.basicConfig(format='%(levelname)s: %(message)s')
> @@ -140,13 +141,25 @@ def send_data(data, args):
> url = args.protocol+args.server+"/ClientPost/"
>
> req = urllib.request.Request(url, data=data, headers=headers)
> +
> + if args.debug:
> + log.debug(f"Request URL: {url}")
> + log.debug(f"Request Headers: {headers}")
> + log.debug(f"Request Data: {data.decode('utf-8')}")
> +
Why only print log.debug if args.debug is set? Isn't that an unnecessary
additional check considering the log.setLevel(logging.DEBUG) in main?
> try:
> response = urllib.request.urlopen(req)
> except urllib.error.HTTPError as e:
> - logging.error(str(e))
> + log.error(f"HTTP Error {e.code}: {e.reason}")
> + log.debug(f"Response Content: {e.read().decode('utf-8')}")
> sys.exit(1)
>
> - print(response.read().decode('utf-8'))
> + if args.debug:
> + log.debug(f"Response Status: {response.status}")
> + log.debug(f"Response Headers: {response.getheaders()}")
> + log.debug(f"Response Content: {response.read().decode('utf-8')}")
> + else:
> + print(response.read().decode('utf-8'))
Same remark here?
It's also a bit odd that the same info is going to be in different log
levels depending on whether debug was enabled or not.
Cheers,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [OE-core][PATCH] send-error-report: improve debugging
2025-04-18 11:27 ` Quentin Schulz
@ 2025-04-18 13:03 ` Thomas Perrot
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Perrot @ 2025-04-18 13:03 UTC (permalink / raw)
To: quentin.schulz, openembedded-core; +Cc: thomas.perrot
[-- Attachment #1: Type: text/plain, Size: 3679 bytes --]
Hello Quentin,
On Fri, 2025-04-18 at 13:27 +0200, Quentin Schulz via
lists.openembedded.org wrote:
> Hi Thomas,
>
> On 4/16/25 12:01 PM, Thomas Perrot via lists.openembedded.org wrote:
> > From: Thomas Perrot <thomas.perrot@bootlin.com>
> >
> > - add a debug mode
> > - print the request and the response when an error occurs.
> >
> > Signed-off-by: Thomas Perrot <thomas.perrot@bootlin.com>
> > ---
> > scripts/send-error-report | 28 ++++++++++++++++++++++++----
> > 1 file changed, 24 insertions(+), 4 deletions(-)
> >
> > diff --git a/scripts/send-error-report b/scripts/send-error-report
> > index cfbcaa52cbc3..cdc1dfc5613a 100755
> > --- a/scripts/send-error-report
> > +++ b/scripts/send-error-report
> > @@ -6,6 +6,7 @@
> > # Copyright (C) 2013 Intel Corporation
> > # Author: Andreea Proca <andreea.b.proca@intel.com>
> > # Author: Michael Wood <michael.g.wood@intel.com>
> > +# Author: Thomas Perrot <thomas.perrot@bootlin.com>
> > #
> > # SPDX-License-Identifier: GPL-2.0-only
> > #
> > @@ -22,7 +23,7 @@ scripts_lib_path =
> > os.path.join(os.path.dirname(os.path.realpath(__file__)), 'li
> > sys.path.insert(0, scripts_lib_path)
> > import argparse_oe
> >
> > -version = "0.3"
> > +version = "0.4"
> >
> > log = logging.getLogger("send-error-report")
> > logging.basicConfig(format='%(levelname)s: %(message)s')
> > @@ -140,13 +141,25 @@ def send_data(data, args):
> > url = args.protocol+args.server+"/ClientPost/"
> >
> > req = urllib.request.Request(url, data=data, headers=headers)
> > +
> > + if args.debug:
> > + log.debug(f"Request URL: {url}")
> > + log.debug(f"Request Headers: {headers}")
> > + log.debug(f"Request Data: {data.decode('utf-8')}")
> > +
>
> Why only print log.debug if args.debug is set? Isn't that an
> unnecessary
> additional check considering the log.setLevel(logging.DEBUG) in main?
I agree that this check is redundant; it is due to a lack of attention.
Thank you, and I will send a revised version.
Kind regards,
Thomas
>
> > try:
> > response = urllib.request.urlopen(req)
> > except urllib.error.HTTPError as e:
> > - logging.error(str(e))
> > + log.error(f"HTTP Error {e.code}: {e.reason}")
> > + log.debug(f"Response Content: {e.read().decode('utf-8')}")
> > sys.exit(1)
> >
> > - print(response.read().decode('utf-8'))
> > + if args.debug:
> > + log.debug(f"Response Status: {response.status}")
> > + log.debug(f"Response Headers: {response.getheaders()}")
> > + log.debug(f"Response Content:
> > {response.read().decode('utf-8')}")
> > + else:
> > + print(response.read().decode('utf-8'))
>
> Same remark here?
>
> It's also a bit odd that the same info is going to be in different
> log
> levels depending on whether debug was enabled or not.
>
> Cheers,
> Quentin
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#215127):
> https://lists.openembedded.org/g/openembedded-core/message/215127
> Mute This Topic: https://lists.openembedded.org/mt/112292245/5443093
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe:
> https://lists.openembedded.org/g/openembedded-core/unsub [
> thomas.perrot@bootlin.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
--
Thomas Perrot, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 659 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-18 13:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-16 10:01 [OE-core][PATCH] send-error-report: improve debugging thomas.perrot
2025-04-18 11:27 ` Quentin Schulz
2025-04-18 13:03 ` Thomas Perrot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.