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

Cannot silence warning downstream because you use logger (replace logger with warnings?) #920

Closed
pllim opened this issue Feb 9, 2022 · 1 comment · Fixed by #922
Closed

Comments

@pllim
Copy link
Member

pllim commented Feb 9, 2022

log = logging.getLogger(__name__)

The warning is driving me crazy and I cannot use warnings to suppress it.

I can suppress it like this but it seems very heavy-handed because that affects everything for the whole session.

import specutils
specutils.spectra.spectrum1d.log.setLevel(40)
@pllim pllim changed the title Cannot silence warning downstream because you use logger Cannot silence warning downstream because you use logger (replace logger with warnings?) Feb 9, 2022
@pllim
Copy link
Member Author

pllim commented Feb 10, 2022

Looking at how loggers are used here, I propose maybe a less controversial solution: Helper functions to globally silence and reset the logger settings. But this is not foolproof because if a downstream package silences it and another package doesn't want that, it can get messy.

A more controversial proposal is as follows:

  • log.info -- If it is really that important to tell user they are doing something wrong, use warnings. If not, just delete it or use print() + verbose keyword.
  • log.warning -- warnings.
  • log.debug -- Use print() + verbose or debug keyword.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant