semuconsulting / pygnssutils

Python GNSS CLI utility library for reading, parsing and broadcasting NMEA, UBX, RTCM3, NTRIP and SPARTN protocols
BSD 3-Clause "New" or "Revised" License
84 stars 25 forks source link

Bug when cycling logfiles #29

Closed garrettseepersad closed 1 year ago

garrettseepersad commented 1 year ago

When cycling the logs, _logpath is overwritten and then creates a runtime error because the logpath had included the previous filename

Problem self._logpath = os.path.join(self._logpath, f"gnssntripclient-{tim}.log")

Solution self._logfilepath = os.path.join(self._logpath, f"gnssntripclient-{tim}.log") with open(self._logfilepath , "a", encoding="UTF-8") as log:

semuadmin commented 1 year ago

Hi @garrettseepersad

Good shout, thanks. On it.

Exception in thread Thread-1 (_read_thread):
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/threading.py", line 975, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/steve/Library/Python/3.11/lib/python/site-packages/pygnssutils/gnssntripclient.py", line 448, in _read_thread
    self._do_data(self._socket, stopevent, ggainterval, output)
  File "/Users/steve/Library/Python/3.11/lib/python/site-packages/pygnssutils/gnssntripclient.py", line 538, in _do_data
    self._do_write(output, raw_data, parsed_data)
  File "/Users/steve/Library/Python/3.11/lib/python/site-packages/pygnssutils/gnssntripclient.py", line 562, in _do_write
    self._do_log(parsed, VERBOSITY_MEDIUM)
  File "/Users/steve/Library/Python/3.11/lib/python/site-packages/pygnssutils/gnssntripclient.py", line 600, in _do_log
    with open(self._logpath, "a", encoding="UTF-8") as log:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
NotADirectoryError: [Errno 20] Not a directory: './gnssntripclient-20230523130251.log/gnssntripclient-20230523130256.log'