ANP-Granular / ParticleTracking

Library and GUI for tracking (rod-like) particles on camera images in 2D and 3D
https://particletracking.readthedocs.io/en/latest/
GNU General Public License v3.0
2 stars 2 forks source link

Logging to a file #55

Closed a-niem closed 2 years ago

a-niem commented 2 years ago

Actions performed in the GUI are now also logged to a file. This file is created in the RodTracker's temporary directory and can be immediatly accessed from the GUI using the "Help" menu. There is only one file created and subsequent sessions are appended to this log file. During program crashes the Exception, that caused it, is written to the log file.

Example of a log:

[08/18 11:46:04] Python.backend.logger INFO: /tmp/RodTracker/Session_gxztadn9
[08/18 11:46:18] Python.backend.logger INFO: (gp3) 25 image file(s) loaded from: /home/niemann/Documents/TrackGUI/SampleData/images/gp3
[08/18 11:46:23] Python.backend.logger INFO: (main) Loaded rod file(s) from: /home/niemann/Documents/TrackGUI/SampleData/csv_extended
[08/18 11:46:35] Python.backend.logger INFO: (gp3, 500, black) Created new rod #26
[08/18 11:46:38] Python.backend.logger WARNING: Removed action: (gp3, 500, black) Created new rod #26
[08/18 13:20:43] Python.backend.logger INFO: /tmp/RodTracker/Session_cxdokl7r
[08/18 13:20:43] Python.backend.logger ERROR: Uncaught exception:
Traceback (most recent call last):
  File "/home/niemann/Documents/TrackGUI/Python/RodTracker.py", line 52, in <module>
    main_window = mw.RodTrackWindow()
  File "/home/niemann/Documents/TrackGUI/Python/ui/mainwindow.py", line 137, in __init__
    raise AttributeError("Test error.")
AttributeError: Test error.
NoneType: None
dmitrypuzyrev commented 2 years ago

It seems that the logger is working well (writing to the file), but it cannot be opened via "Help" menu (as well as Readme). See the logged excerptions, seems easily fixable:

[08/23 16:35:48] Python.backend.logger INFO: C:\Users\Dmitry\AppData\Local\Temp/RodTracker\Session_tv0s128d
[08/23 16:35:52] Python.backend.logger ERROR: Uncaught exception:
Traceback (most recent call last):
  File "C:\Users\Dmitry\Documents\GitHub\Track_Gui\Python\backend\logger.py", line 52, in open_logs
    os.startfile(LOG_PATH)
NameError: name 'os' is not defined
NoneType: None
[08/23 16:38:17] Python.backend.logger ERROR: Uncaught exception:
Traceback (most recent call last):
  File "C:\Users\Dmitry\Documents\GitHub\Track_Gui\Python\backend\logger.py", line 52, in open_logs
    os.startfile(LOG_PATH)
NameError: name 'os' is not defined
NoneType: None
[08/23 16:38:19] Python.backend.logger ERROR: Uncaught exception:
Traceback (most recent call last):
  File "C:\Users\Dmitry\Documents\GitHub\Track_Gui\Python\ui\mainwindow.py", line 278, in <lambda>
    self))
  File "C:\Users\Dmitry\Documents\GitHub\Track_Gui\Python\ui\dialogs.py", line 584, in show_readme
    docs_dialog.docs.setMarkdown(readme_md)
AttributeError: 'QTextEdit' object has no attribute 'setMarkdown'
NoneType: None
a-niem commented 2 years ago

Access to the logs on windows is now possible. @dmitrypuzyrev Can you please check what version of the PyQt5 package is installed. There might be a mismatch between your version and the required version.

dmitrypuzyrev commented 2 years ago

I have reinstalled Anaconda and now have PyQt 5.9.2 (which still seems to be pretty old). The Readme does not open, and now there is no error message. Which PyQt version is required?

a-niem commented 2 years ago

The requirements.txt file specifies 5.15.4. You can make sure to have the required libraries by using this file for the installation:

$ conda install pip
$ pip install -r requirements.txt