From ea87bafc957380c8d2a6092e5769eac155e2e049 Mon Sep 17 00:00:00 2001 From: mutesplash <49622611+mutesplash@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:14:46 -0500 Subject: [PATCH 1/3] Public access to the filename of the debug log --- buildhat/hat.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/buildhat/hat.py b/buildhat/hat.py index 395a3d6..227b054 100644 --- a/buildhat/hat.py +++ b/buildhat/hat.py @@ -41,6 +41,9 @@ def get(self): "description": desc} return devices + def get_logfile(self): + return Device._instance.debug_filename + def get_vin(self): """Get the voltage present on the input power jack From 338296334f65ffad2e9b04d20de991bebb447cad Mon Sep 17 00:00:00 2001 From: mutesplash <49622611+mutesplash@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:15:39 -0500 Subject: [PATCH 2/3] Save debug log filename vs throwing it away in the logging framework --- buildhat/serinterface.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildhat/serinterface.py b/buildhat/serinterface.py index c8e5063..77ee53e 100644 --- a/buildhat/serinterface.py +++ b/buildhat/serinterface.py @@ -94,8 +94,10 @@ def __init__(self, firmware, signature, version, device="/dev/serial0", debug=Fa self.motorqueue = [] self.fin = False self.running = True + self.debug_filename = None if debug: tmp = tempfile.NamedTemporaryFile(suffix=".log", prefix="buildhat-", delete=False) + self.debug_filename = tmp.name logging.basicConfig(filename=tmp.name, format='%(asctime)s %(message)s', level=logging.DEBUG) From 057e98662990c54ed0d8593d2f048f1e947da2fe Mon Sep 17 00:00:00 2001 From: mutesplash <49622611+mutesplash@users.noreply.github.com> Date: Wed, 29 Nov 2023 09:31:07 -0500 Subject: [PATCH 3/3] Flake8 compliance --- buildhat/hat.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/buildhat/hat.py b/buildhat/hat.py index 227b054..0a277eb 100644 --- a/buildhat/hat.py +++ b/buildhat/hat.py @@ -42,6 +42,11 @@ def get(self): return devices def get_logfile(self): + """Get the filename of the debug log (If enabled, None otherwise) + + :return: Path of the debug logfile + :rtype: str or None + """ return Device._instance.debug_filename def get_vin(self):