-
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
Changes from all commits
00a786e
126e2b9
753ead6
be1c7b6
e447b34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ | |
|
|
||
| from . import constants | ||
| from . import dirs | ||
| from .logger import logger | ||
|
|
||
| def parse_cli(): | ||
| try: | ||
|
|
@@ -138,7 +139,7 @@ def parse_cli(): | |
| ) | ||
| return parser.parse_args() | ||
| except argparse.ArgumentError as err: | ||
| print(str(err)) | ||
| logger.error(str(err)) | ||
leotrs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sys.exit(2) | ||
|
|
||
|
|
||
|
|
@@ -225,8 +226,8 @@ def get_camera_configuration(args): | |
| try: | ||
| camera_config["background_color"] = colour.Color(args.color) | ||
| except AttributeError as err: | ||
| print("Please use a valid color") | ||
| print(err) | ||
| logger.warning("Please use a valid color") | ||
| logger.error(err) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| sys.exit(2) | ||
|
|
||
| # If rendering a transparent image/move, make sure the | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| import logging | ||
| from rich.logging import RichHandler | ||
|
|
||
|
|
||
| logging.basicConfig( | ||
| level="NOTSET", | ||
| format="%(message)s", | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| datefmt="[%X]", | ||
| handlers=[RichHandler()] | ||
| ) | ||
|
|
||
| logger = logging.getLogger("rich") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,5 +26,6 @@ | |
| "pydub", | ||
| "pygments", | ||
| "pyreadline; sys_platform == 'win32'", | ||
| "rich" | ||
| ], | ||
| ) | ||
Uh oh!
There was an error while loading. Please reload this page.