Info level logging messages do not appear in Python console

I built the latest Slicer 5.3, and I now see the changes in the Python console. It’s great to see Qt and VTK errors there too.

However, one thing that could make my day to day work very hard is that the output from calls in the executed code do not appear in the console. Is there any way to turn this back on? Thank you!

Have you gone into application settings to change log level from the default Warning to Info?

That was easy then, thanks. I thought it would be a CMake option or something similar, that’s why I asked.

I’m wondering why warning is the default log level instead of info? The difference between debug and info is that although neither of them indicate errors, the debug messages don’t appear in the console but the info ones do. Now if you don’t change the setting, there is no difference between the two.

Logging and process output in Python were previously somewhat intermixed, as it was not possible to print a message on the Python console without making that also show up in the process output and therefore in the application log. After the logging system rework, it has become possible to clearly separate logs, process output, and Python console output, which allowed to display log messages from any sources (Qt, VTK, ITK, CTK, …) in the Python console.

We just had to decide what log level to display in the Python console. Since debug and info messages usually not that important and anything that we want to appear in the process output can be displayed using print, we decided the default log level to be warning and make it easy to change it in application settings.

If you want to display messages in the Python console from Python code, then I would recommend following options (which are the standard way of doing this in Python):

  • A. register an additional Python logger, which prints info-level messages to the process output/Python console (if this is information that user might be interested in), or
  • B. use print instead of (if users must see it, because for example that is the result of the command, not just some additional optional information).

Thanks for the answer! After setting the level (as you said, easily) to info, I can see what I want in the console - I usually info-log the main steps in my modules, and it’s easy to see where errors occured, if the values are still sensible etc.

By the way I expect way more work happening in the future about fixing errors, just so that they don’t clog up the console :slight_smile: