python-microscope / microscope

Python library for control of microscope devices, supporting hardware triggers and distribution of devices over the network for performance and flexibility.
https://www.python-microscope.org
GNU General Public License v3.0
69 stars 41 forks source link

device server has too many logging messages and no option to change logging level #168

Closed iandobbie closed 3 years ago

iandobbie commented 4 years ago

The deepstar laser code produces a console message every few seconds which is stupid. Needs to be suppressed in general usage.

carandraug commented 4 years ago

Most of the devices, the deepstar laser included, use the info level for many of its messages. I guess we could change them to debug.

However, I think the root cause is that the device server changes the default logging level at start to debug (well, if __debug__ is true which typically is). We should probably have a command line option for this.

carandraug commented 3 years ago

I just set up a test deformable mirror to try Nick's aotools. This issue makes it impossible to get anything out of the logs, there's just too much stuff happening there. We can't default to debug log level.

carandraug commented 3 years ago

I have added an --logging-level command line option to device-server and made it default to info. I'm not sure about it, I can also think of many reasons to have it default to warning. The thing that made me chose info in the end, was that printing the device URI is obviously info, and that's something that seems sensible to print by default. Also, if default is set to warning, nothing is printed and the feeling is that nothing is happening. The old unix silence is golden rule makes more sense to command line tools to be used interactively which is not the case of the device-server (which is more akin to a daemon).

Closing as fixed but I think its worth having a look at messages being logged and thinking twice about their level. There's some stuff which I think would fit debug better than info.

carandraug commented 3 years ago

[...] Closing as fixed but I think its worth having a look at messages being logged and thinking twice about their level. There's some stuff which I think would fit debug better than info.

I just did it for the DeepstarLaser which is what triggered this issue. The message that kept spamming the console was "Are we on? [S1]" which was info level. This was emitted every time get_is_on is called which Cockpit does every second or so. That message is now debug level (as well as many other).