Handlers that do not add newline characters #73
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I was trying to sync
molecule.py
andnifty.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 callinglogger.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
andRawFileHandler
whose behaviors are the same aslogging.StreamHandler
andlogging.FileHandler
respectively, except that they do not automatically include a newline character at the end of each message. Thelog.ini
file has been modified to use these two handlers andlogJson.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 inrotate.py
,internal.py
andoptimize.py
. From the user's perspective, the terminal messages and log files should be the same as before.