-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add logger and replace print calls with appropriate logging functions #59
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
Conversation
This commit adds a logger.py file and also replaces all `print` calls with logging functions like `logger.info`, `logger.warning`, `logger.error` etc. Also adds rich as a dependency.
Aathish04
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works flawlessly.
FOR FUTURE CONSIDERATION:
Implementing custom colour palettes.
leotrs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like where this is going. The next step is to add logging messages where there were none. Maybe a separate PR?
| print("Please use a valid color") | ||
| print(err) | ||
| logger.warning("Please use a valid color") | ||
| logger.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These two should be logged at the same level; it looks like it should be error here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could be fancy and use logger.exception(). Likewise inside the other exception blocks.
| ## Setting config for logger. | ||
| logging.basicConfig( | ||
| level="NOTSET", | ||
| format="%(message)s", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually think the filename could come in handy in logs. Maybe something that could be flag-configurable later.
| print("Please use a valid color") | ||
| print(err) | ||
| logger.warning("Please use a valid color") | ||
| logger.error(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or you could be fancy and use logger.exception(). Likewise inside the other exception blocks.

This commit adds a logger.py file and also replaces all
printcalls with logging functions likelogger.info,logger.warning,logger.erroretc.Also adds rich as a dependency.