Skip to content

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

Merged
penguinolog merged 1 commit into
urwid:masterfrom
penguinolog:logging
Dec 27, 2023
Merged

Feature: Use module path + class name for loggers and init once#720
penguinolog merged 1 commit into
urwid:masterfrom
penguinolog:logging

Conversation

@penguinolog

Copy link
Copy Markdown
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
Copy Markdown

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
Comment thread urwid/display_common.py
def __init__(self) -> None:
super().__init__()

self.logger = LOGGER.getChild(self.__class__.__name__)

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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