ecmwf / ecmwf-api-client

Python API to access ECMWF archive
Apache License 2.0
66 stars 20 forks source link

Print statements to logging #17

Closed din14970 closed 2 years ago

din14970 commented 2 years ago

We want to use the API in remote automated workflows but print statements are incompatible with live streaming of log outputs. Given that requests can take hours, this makes it very frustrating to debug the application when no output is visible. I propose to change the print statements to logging output so that it can be more easily streamed and controlled.

cristian-codorean commented 2 years ago

Thank you @din14970. Please see the attached pull request with improvements to allow the use of Python's logging module instead of print statements. Do let me know if any comments. If not, will go ahead and produce an API release with these changes ASAP.

din14970 commented 2 years ago

@cristian-codorean yep looks better now, although in my opinion there is a lot of stuff that could be simplified if logging was used directly in the module, instead of working with all these booleans like verbose etc. Simply replacing everything with debug in places where verbose is checked, then the user can set logging detail with logging settings. Just a thought.

cristian-codorean commented 2 years ago

Point taken. Will go ahead and release the changes made so far, since there's a bit of tidying up of the code in there as well, then look into fully moving to the logging module. Did not want to make any breaking changes but, to be honest, I'm not sure many users use the log, verbose, and quiet arguments of the 2 main API classes.