Skip to content

Add debug log filename access #204

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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