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

Replace print() statements with logging #25

Merged
merged 13 commits into from
Oct 2, 2024
Merged

Conversation

measrainsey
Copy link
Contributor

@measrainsey measrainsey commented Sep 3, 2024

Simple PR to replace print() statements with python's logging functions.

This should fix #24.

I've implemented a custom logger that:

  • creates logs at each module level (__name__)
  • sets the logging level at logging.info()
  • saves the logs to a file that is the name of the module (I've added .log files to .gitignore)
  • adds some additional syntax such as date and time

For example, running run_preprocess.py results in the following log files:

  • main.log
  • message_ix_buildings.chilled.preprocess.archetypes.log
  • message_ix_buildings.chilled.util.util.log

Hopefully a simple review, but please let me know if I should fix anything.

@measrainsey measrainsey added enhancement New feature or request chilled PRs and issues related to the CHILLED model labels Sep 3, 2024
@measrainsey measrainsey self-assigned this Sep 3, 2024
@measrainsey measrainsey marked this pull request as ready for review September 3, 2024 14:01
Copy link
Member

@glatterf42 glatterf42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall and always a great idea to use python logging over print(). Please see my suggestions before merging, though :)

message_ix_buildings/chilled/util/util.py Outdated Show resolved Hide resolved
message_ix_buildings/chilled/util/util.py Outdated Show resolved Hide resolved
message_ix_buildings/chilled/util/util.py Outdated Show resolved Hide resolved
@measrainsey measrainsey merged commit c370db9 into main Oct 2, 2024
@measrainsey measrainsey deleted the chilled/logging branch October 2, 2024 11:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chilled PRs and issues related to the CHILLED model enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CHILLED code is using print() statements instead of logging
2 participants