Skip to content

Feature: Use module path + class name for loggers and init once #720

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

Merged
merged 1 commit into from
Dec 27, 2023

Conversation

penguinolog
Copy link
Collaborator

  • Add logger to all Widget instances (if properly subclassed)
Checklist
  • I've ensured that similar functionality has not already been implemented
  • I've ensured that similar functionality has not earlier been proposed and declined
  • I've branched off the master or python-dual-support branch
  • I've merged fresh upstream into my branch recently
  • I've ran tox successfully in local environment
  • I've included docstrings and/or documentation and/or examples for my code (if this is a new feature)

* Add `logger` to all `Widget` instances (if properly subclassed)
@penguinolog penguinolog added the Feature Feature request/implementation label Dec 27, 2023
@coveralls
Copy link

Pull Request Test Coverage Report for Build 7336966911

  • 3 of 7 (42.86%) changed or added relevant lines in 2 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.003%) to 71.017%

Changes Missing Coverage Covered Lines Changed/Added Lines %
urwid/display_common.py 0 1 0.0%
urwid/widget/widget.py 3 6 50.0%
Files with Coverage Reduction New Missed Lines %
urwid/_raw_display_base.py 1 6.2%
Totals Coverage Status
Change from base Build 7336954258: 0.003%
Covered Lines: 7596
Relevant Lines: 10794

💛 - Coveralls

@penguinolog penguinolog merged commit 418864a into urwid:master Dec 27, 2023
@penguinolog penguinolog deleted the logging branch December 27, 2023 09:42
@@ -1004,7 +1003,7 @@ class BaseScreen(metaclass=BaseMeta):
def __init__(self) -> None:
super().__init__()

self.logger = LOGGER.getChild(self.__class__.__name__)
Copy link
Collaborator

Choose a reason for hiding this comment

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

this logger could be part of the class instead of the instance so it doesn't have to be tracked in every single widget

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will require metaclass usage, which is a bit overkill

Copy link
Collaborator

Choose a reason for hiding this comment

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

It could also be a Widget property or method that returns the logger

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Technically once logger initializer, it stored in logging.Manager, so all instances of the same Widget class uses the same Logger.
Adding property may break downstream, because it will cause errors if downstream initialize logger itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Feature request/implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants