Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agree on a "printing and logging" convention for PyKE #88

Open
barentsen opened this issue Aug 14, 2017 · 0 comments · May be fixed by #189
Open

Agree on a "printing and logging" convention for PyKE #88

barentsen opened this issue Aug 14, 2017 · 0 comments · May be fixed by #189

Comments

@barentsen
Copy link
Member

barentsen commented Aug 14, 2017

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?

ecalifornica added a commit to ecalifornica/pyke that referenced this issue Feb 18, 2018
This is a first pass at issue KeplerGO#88, converting pyke to more Pythonic
logging.
@ecalifornica ecalifornica linked a pull request Feb 18, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants