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

Add CustomLogger to prevent IDE lint warnings when calling log.trace. #1831

Merged
merged 3 commits into from Oct 14, 2021

Conversation

TizzySaurus
Copy link
Contributor

@TizzySaurus TizzySaurus commented Sep 17, 2021

Closes #1830

Implements the proposed CustomLogger class to fix the lint warnings.

@TizzySaurus TizzySaurus added t: bug Something isn't working a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve labels Sep 17, 2021
@Xithrius
Copy link
Member

Xithrius commented Sep 17, 2021

Here is the CustomLogger class, so anyone reviewing this doesn't have to scroll to find it.

@Xithrius Xithrius added p: 3 - low Low Priority and removed p: 2 - normal Normal Priority labels Sep 17, 2021
@TizzySaurus
Copy link
Contributor Author

TizzySaurus commented Sep 17, 2021

Here is the CustomLogger class, so anyone reviewing this doesn't have to scroll to find it.

There's also the get_logger util function (entire file is new)

All other changes are removing the old monkeypatch trace or updating imports from

import logging

log = logging.getLogger(__name__)

to

from bot.utils.logging import get_logger

log = get_logger(__name__)

@Xithrius Xithrius removed the request for review from ks129 September 17, 2021 12:43
Copy link
Member

@kosayoda kosayoda left a comment

Choose a reason for hiding this comment

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

Nice, I've personally wanted this for a while 👍🏻

Missing log migration: bot/exts/recruitment/talentpool/_cog.py

bot/log.py Outdated Show resolved Hide resolved
bot/log.py Outdated Show resolved Hide resolved
@TizzySaurus
Copy link
Contributor Author

TizzySaurus commented Sep 18, 2021

NB: Linting & Test checks currently failing due to maintenance on the coveralls API. Will rerun checks later 👍

Edit: coveralls has now been removed (see #1838) so just waiting for reviews now

@TizzySaurus
Copy link
Contributor Author

NB: The getLogger in bot.utils.members will also need to be migrated once #1837 has been merged.

@TizzySaurus TizzySaurus dismissed kosayoda’s stale review September 23, 2021 09:43

requested changes have been pushed.

Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

I'm not sure using log = logging.getLogger(__name__) is the best solution to the circular import problem, although i'm not sure what is either...

Other than that this looks good.

bot/constants.py Outdated Show resolved Hide resolved
bot/utils/services.py Outdated Show resolved Hide resolved
@TizzySaurus TizzySaurus force-pushed the custom-logger-class branch 4 times, most recently from b7cc69f to 4b8aea9 Compare October 5, 2021 20:30
@TizzySaurus
Copy link
Contributor Author

TizzySaurus commented Oct 5, 2021

Have fixed the root issue of the circular imports, so now all files should be using bot.log.get_logger instead of logging.getLogger.

Also added any missing migrations from PRs made after I started this and squashed, fixed the conflicts (all 25), split the initial commit into two (one for creating the new class and second for the migrations), and did a commit for making newlines after imports consistent (part of PyCharm's "Optimize Imports" feature).

This should now be fully read for review @kosayoda @wookie184 👍

Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

Two small things, other than that it looks good.

bot/constants.py Outdated Show resolved Hide resolved
bot/constants.py Outdated Show resolved Hide resolved
Copy link
Contributor

@wookie184 wookie184 left a comment

Choose a reason for hiding this comment

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

All seems good to me 👍

Copy link
Member

@Xithrius Xithrius left a comment

Choose a reason for hiding this comment

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

Approving on @ChrisLovering's behalf.

And also my own.

@ChrisLovering ChrisLovering merged commit 1ca6d57 into main Oct 14, 2021
@ChrisLovering ChrisLovering deleted the custom-logger-class branch October 14, 2021 21:27
@TizzySaurus TizzySaurus mentioned this pull request Oct 27, 2021
@Xithrius Xithrius removed the s: needs review Author is waiting for someone to review and approve label Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: backend Related to internal functionality and utilities (error_handler, logging, security, utils and core) p: 3 - low Low Priority t: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Unresolved attribute reference 'trace' for class 'Logger'"
5 participants