Skip to content

fetch-configlet: use logging module instead of print#2188

Merged
cmccandless merged 3 commits into
exercism:masterfrom
cmccandless:fetch-configlet-logging
Mar 8, 2020
Merged

fetch-configlet: use logging module instead of print#2188
cmccandless merged 3 commits into
exercism:masterfrom
cmccandless:fetch-configlet-logging

Conversation

@cmccandless
Copy link
Copy Markdown
Contributor

No description provided.

@cmccandless cmccandless requested a review from a team as a code owner March 6, 2020 14:14
@cmccandless cmccandless self-assigned this Mar 6, 2020
Comment thread bin/fetch-configlet Outdated


logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__file__)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This should be __name__ not __file__.

Comment thread bin/fetch-configlet Outdated
Comment thread bin/fetch-configlet Outdated
Comment thread bin/fetch-configlet Outdated
Comment thread bin/fetch-configlet Outdated
Copy link
Copy Markdown
Contributor

@yawpitch yawpitch 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 except for the logging.getLogger(__file__) ... IIRC the logging module assumes that a dot in the name indicates a child logger, so the relative file path would make it go a bit nuts if we ever added submodules to this.

It won't get in the way as is, so I'll approve, but I'd still fix that one before merge if you can.

Comment thread bin/fetch-configlet
Comment on lines +88 to +89
logger.error(f"Received unexpected {status} response from API: {response}")
return 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

FWIW, I originally did that as sys.exit() because my thinking was a client error other than a 403 from the API is probably a permanent condition within the lifetime of the script run. Probably doesn't matter either way.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Intent noted. It still seems the wrong approach to allow the function itself to trigger a full program exit. If we wanted to keep that short-circuit functionality, the best approach would probably be to raise some sort of unique exception to allow the caller to handle the failure however it wishes.

Comment thread bin/fetch-configlet
@cmccandless cmccandless merged commit 4499a2b into exercism:master Mar 8, 2020
@cmccandless cmccandless deleted the fetch-configlet-logging branch March 8, 2020 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants