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

Consistent use of logger? #233

Open
DrDomenicoMarson opened this issue Sep 19, 2022 · 4 comments
Open

Consistent use of logger? #233

DrDomenicoMarson opened this issue Sep 19, 2022 · 4 comments

Comments

@DrDomenicoMarson
Copy link
Contributor

I was trying to figure out how to make better use of logger/raise in the AMBER parser, and I checked other files in the project, so I took the advance and made a list of something I observed.

I have some comments for these files:

  • parsing/amber --> some Exceptions handled with logger.exception without raising a proper exception (this I have to change in issue AMBER: inconsistent use of raise Exception / logger.exception #227

  • parsing/gmx --> no logger, but also no raise (it's impossible to get an error while reading a gmx file?)

  • parsing/gomc --> no logger, but also no raise (no possible errors in the file?)

  • parsing/namd --> coherent, lot of logger.error/warning followed directly with a raise (maybe missing one at lines 81 and 239)

  • parsing/util --> no logger, but we have a raise ValueError without logging the error at line 79

  • postprocessors/units --> no logger, but we have different raise SOMETHING, without logging

  • preprocessing/subsampling --> no logger, but we have different raise SOMETHING, without logging

  • visualisation/* --> no logger, but we have different raise SOMETHING, without logging

  • init/concat --> no logger, just raised two ValueError without logging

I don't know if everything here is what is supposed to be, I'm new to the use of the logging module, I just wanted to report where I saw many raise without the logging of some information.

Also, I noticed in some modules more than others we are extensively using logger.info, while in many more modules logger.info is never used, what's the rationale behind the decision to log something to info?
info is printed just if we increase the level of logging information right? Are we doing so in some part of the code?

@DrDomenicoMarson DrDomenicoMarson changed the title How/where are we using logger? Consistent use of logger? Sep 19, 2022
@xiki-tempula
Copy link
Collaborator

xiki-tempula commented Sep 19, 2022

The package was started a long time ago and various functions are added by various people across a very long period so the logging/exception/warning is not set up in a uniformed standard.

My feeling is that if there is something that you wish the user to know it will be through logging.info
If there is a warning, then it should be

logging.warning(msg)
warning.warn(msg)

If there is an exception, it should be

logging.exception(msg)
raise Exception(msg)

These are the ideal standards but I'm well aware that almost no functions obey this.

@DrDomenicoMarson
Copy link
Contributor Author

Great, I'll try to follow the more standard practice with my commits then!

@orbeckst
Copy link
Member

orbeckst commented Nov 8, 2022

See also #34

@orbeckst
Copy link
Member

orbeckst commented Jun 6, 2023

Help is welcome — with PR #303 we now use loguru everywhere, which has a more modern syntax than logging. Please feel free to add logging where necessary.

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

No branches or pull requests

3 participants