We need a convention on how PyKE should deal with printing feedback to the users and writing logfiles. The current system based on verbose and logfile arguments is not in line with the logging mechanisms used by major scientific packages. I propose the following:
Main principles
- There shall be no
print statements anywhere.
- All user feedback messages shall be delivered via a new
keplog.log(level, message) function, which in turn shall make use of either Python's or AstroPy's built-in logging framework, which support different levels of logging (ERROR, WARNING, INFO, DEBUG).
Consequences
- The
verbose arguments shall be removed in favor of the config mechanisms provided by the logging framework. A convenience function called keplog.set_level can be added to help users set the log level (e.g. keplog.set_level(DEBUG)). The command-line tools can have a user-friendly --silent or --debug option to set the log level to ERROR or DEBUG, respectively.
- All
logfile arguments shall be removed in favor of the config mechanisms offered by the logging framework. A convenience function called e.g. keplog.set_logfile can be added to help users divert output to a logfile.
Other conventions
- Whenever PyKE writes a file, it must be reported to the user via
keplog.log(INFO, "Writing " + filename).
- Progressbars shall have their
desc and disable argument set, i.e.
tqdm(iterable, desc="Informative description", disable=(keplog.get_level() <= INFO))
- Command-line tools should catch all exceptions and print them via
keplog.log(ERROR, msg).
What do y'all think?
We need a convention on how PyKE should deal with printing feedback to the users and writing logfiles. The current system based on
verboseandlogfilearguments is not in line with the logging mechanisms used by major scientific packages. I propose the following:Main principles
printstatements anywhere.keplog.log(level, message)function, which in turn shall make use of either Python's or AstroPy's built-inloggingframework, which support different levels of logging (ERROR,WARNING,INFO,DEBUG).Consequences
verbosearguments shall be removed in favor of the config mechanisms provided by the logging framework. A convenience function calledkeplog.set_levelcan be added to help users set the log level (e.g.keplog.set_level(DEBUG)). The command-line tools can have a user-friendly--silentor--debugoption to set the log level toERRORorDEBUG, respectively.logfilearguments shall be removed in favor of the config mechanisms offered by the logging framework. A convenience function called e.g.keplog.set_logfilecan be added to help users divert output to a logfile.Other conventions
keplog.log(INFO, "Writing " + filename).descanddisableargument set, i.e.tqdm(iterable, desc="Informative description", disable=(keplog.get_level() <= INFO))keplog.log(ERROR, msg).What do y'all think?