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
66 stars 38 forks source link

Redirect logging messages from local logger to external one #268

Closed jacopoabramo closed 1 year ago

jacopoabramo commented 1 year ago

Greetings,

I'm currently implementing python-microscope within ImSwitch, a software which has its own internal logger which I wanted to take advantage of to keep consistency with the logging messages. Would it be possible to redirect the microscope's logging messages to a different one? And if so, how? It's not really an "issue" per se, but I could not find the discussion tab in the repo.

Thank you!

carandraug commented 1 year ago

Microscope simply uses Python's logging module. You "just" need to set the handlers to wherever you want the logs to go. The how depends on where you're starting the device server and what logging system does ImSwitch is using.

jacopoabramo commented 1 year ago

Great, then I'll dive deep into how to do this in ImSwitch. Thanks! Closing.

iandobbie commented 1 year ago

As far as I understand it you just need to replace the log_handler in device_server.py somewhere around line 350. I have been playing with this to add a defined path rather than the cwd see #267