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

Handlers that do not add newline characters #73

Merged
merged 5 commits into from
Apr 1, 2019
Merged

Conversation

leeping
Copy link
Owner

@leeping leeping commented Mar 31, 2019

I was trying to sync molecule.py and nifty.py across ForceBalance and geomeTRIC when I noticed that the codes do not print out the same messages in both packages because the logging behavior is different. ForceBalance loggers do not add a newline character by default whereas geomeTRIC does, so any code that was calling logger.info was printing out extra newline characters in geomeTRIC.

I originally added the "no-newline" behavior in ForceBalance because I wanted to have finer control over what was printed to the terminal. I had run into some of these issues in geomeTRIC as well, especially when printing out arrays for debugging purposes. Thus, I think the behavior of geomeTRIC logging should be made consistent with ForceBalance logging.

This PR resolves the issue by adding two handlers to nifty.py, RawStreamHandler and RawFileHandler whose behaviors are the same as logging.StreamHandler and logging.FileHandler respectively, except that they do not automatically include a newline character at the end of each message. The log.ini file has been modified to use these two handlers and logJson.ini has been added in order to keep the JSON interface behavior the same as before. I also updated all of the log messages to have explicit newline characters in rotate.py, internal.py and optimize.py. From the user's perspective, the terminal messages and log files should be the same as before.

@codecov-io
Copy link

codecov-io commented Mar 31, 2019

Codecov Report

Merging #73 into master will decrease coverage by 0.39%.
The diff coverage is 30.9%.

@leeping leeping self-assigned this Mar 31, 2019
@leeping leeping merged commit ed832c5 into master Apr 1, 2019
@leeping leeping deleted the rawstreamhandler branch July 4, 2020 23:45
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 this pull request may close these issues.

2 participants