For ease of testing a WIP module, I will often start Slicer from a bash shell, so that I could save its output to a log programmatically. However, when I went to refactor my many print statements into logging calls, I noticed that they no longer appeared. Digging deeper, it seems that calling Slicer from the command line results in a pretty substantial de-sync.
Qt logs are properly displayed in both the Python and Bash console
print statements are only shown in the Bash console
logging statements are only shown in the Python console
Is their something I’m missing? This is on Slicer 5.8.1, called within a ScriptedLoadableModuleWidget and VTKObservationMixin subclass, with get_cart_logger simply being a wrapper for a logging.getLogger call with some tracking strapped on. Any insight on this would be appreciated.
Console is only available in certain environments (e.g., no console on Windows GUI applications), so Slicer does not depend on it and I would not recommend for debugging.
You can access logs in the application log file (slicer.app.errorLogModel().filePath). You can also add a callback function to the error log model object to get notified when something is logged and can get any log messages like this: