Skip to content

Conversation

@kilacoda-old
Copy link
Contributor

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.

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.
@kilacoda-old kilacoda-old added the enhancement Additions and improvements in general label May 22, 2020
Copy link
Member

@Aathish04 Aathish04 left a 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.

@huguesdevimeux huguesdevimeux linked an issue May 22, 2020 that may be closed by this pull request
Copy link
Contributor

@leotrs leotrs left a 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)
Copy link
Member

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.

Copy link
Member

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",
Copy link
Member

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)
Copy link
Member

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.

@huguesdevimeux
Copy link
Member

huguesdevimeux commented May 22, 2020

Just a small thing,
image

Could you do something about the formatting of that? Because it looks ugly next to the great formatting of the logs.

EDIT: On second thought I don't know. I'm not an artistic guy, maybe it's better like that

@kilacoda-old kilacoda-old removed the request for review from PgBiel May 23, 2020 00:54
@kilacoda-old kilacoda-old merged commit b265ad1 into master May 23, 2020
@leotrs leotrs deleted the logging-with-rich branch May 23, 2020 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Additions and improvements in general

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use a logging library

8 participants