ccsdspy icon indicating copy to clipboard operation
ccsdspy copied to clipboard

Move to using logging module

Open ehsteve opened this issue 1 year ago • 5 comments

It would make it easier for folks using this package in pipelines if all of its output was provided in a log file. The Python logging module does exactly this. For example, one change which would be helpful would be to move from using warnings.warn and use logging.warn.

ehsteve avatar Mar 05 '25 19:03 ehsteve

Should this be considered a backwards incompatible change?

ddasilva avatar Mar 05 '25 19:03 ddasilva

This could be very helpful! I'm already using the python logging module for my wider codebase that uses ccsdspy, would your implementation of logging somehow allow specifying the log to output to? That way I could see ccsdspy warnings/errors in my existing log along with my other stuff as currently they are just printed to the stdout

Hydravine avatar Mar 05 '25 20:03 Hydravine

We also use the logging module. My understand that it is possible to use multiple loggers together or configure loggers how you want to use them.

ehsteve avatar Mar 12 '25 18:03 ehsteve

Is there an implementation choice in using the global logger versus passing a logger object to each function? Or maybe create an global API setter ccsdspy.set_logger(logger)? It's been a while since I used the logging module

ddasilva avatar Mar 12 '25 18:03 ddasilva

Given my understanding of logging, you just set up your local logger and don't need to do anything special. It should be from ccsdspy import log. Users can then merge logs with their own loggers or do something different. I think we can easily add logging the way we do it and we can get feedback on whether that is the right approach.

ehsteve avatar Mar 14 '25 14:03 ehsteve