Skip to content

Commit

Permalink
Merge pull request #204 from mutesplash/patch-3
Browse files Browse the repository at this point in the history
Add debug log filename access
  • Loading branch information
grega authored Dec 19, 2023
2 parents 2536042 + 057e986 commit af1bfd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions buildhat/hat.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def get(self):
"description": desc}
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):
"""Get the voltage present on the input power jack
Expand Down
2 changes: 2 additions & 0 deletions buildhat/serinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit af1bfd7

Please sign in to comment.