hongquanli / octopi-research

BSD 3-Clause "New" or "Revised" License
36 stars 36 forks source link

logging: add logging mechanism, hooks to log uncaught crashes, and an example use of the logging tools #114

Closed ianohara closed 3 weeks ago

ianohara commented 4 weeks ago

This adds logging tools in the octopi.logging module (along with the octopi package), and two helpers there for getting loggers and setting the octopi logger logging level. This allows us to have a dedicated hierarchy of loggers that we can configure while leaving all the loggers setup by other libraries alone.

It also adds an example usage in the control._def.py module. We can start converting individual files after this.

It also lays the groundwork for better crash reports by allowing us to hook up handlers for uncaught exceptions. By default these just print to console, but we want to be able to hook up a FileHandler to our logger and have the uncaught exceptions go there as well. Actually creating the FileHandler and attaching it to the root octopi logger is to come.

Tested by: Attempting to run main_hcs.py, and seeing log messages: image

I also added a random raise ValueError("test test") in main_hcs.py for a different run to make sure that the handlers work as expected: image

ianohara commented 4 weeks ago

I will rebase on #113 once (if) it lands. I can't select a pull request base that's not pushed to this fork, so can't get rid of that noise. Sorry :/

hongquanli commented 3 weeks ago

This adds logging tools in the octopi.logging module (along with the octopi package), and two helpers there for getting loggers and setting the octopi logger logging level. This allows us to have a dedicated hierarchy of loggers that we can configure while leaving all the loggers setup by other libraries alone.

It also adds an example usage in the control._def.py module. We can start converting individual files after this.

It also lays the groundwork for better crash reports by allowing us to hook up handlers for uncaught exceptions. By default these just print to console, but we want to be able to hook up a FileHandler to our logger and have the uncaught exceptions go there as well. Actually creating the FileHandler and attaching it to the root octopi logger is to come.

Tested by: Attempting to run main_hcs.py, and seeing log messages: image

I also added a random raise ValueError("test test") in main_hcs.py for a different run to make sure that the handlers work as expected: image

@ianohara can you change octopi to squid?

ianohara commented 3 weeks ago

This adds logging tools in the octopi.logging module (along with the octopi package), and two helpers there for getting loggers and setting the octopi logger logging level. This allows us to have a dedicated hierarchy of loggers that we can configure while leaving all the loggers setup by other libraries alone. It also adds an example usage in the control._def.py module. We can start converting individual files after this. It also lays the groundwork for better crash reports by allowing us to hook up handlers for uncaught exceptions. By default these just print to console, but we want to be able to hook up a FileHandler to our logger and have the uncaught exceptions go there as well. Actually creating the FileHandler and attaching it to the root octopi logger is to come. Tested by: Attempting to run main_hcs.py, and seeing log messages: image I also added a random raise ValueError("test test") in main_hcs.py for a different run to make sure that the handlers work as expected: image

@ianohara can you change octopi to squid?

Yep, will do. Also I'll move this over to https://github.com/Cephla-Lab/Squid