Skip to content

🔧 Open up logging - #237

Merged
keithrfung merged 3 commits into
mainfrom
feature/open-up-logging
Oct 30, 2020
Merged

keithrfung merged 3 commits into
mainfrom
feature/open-up-logging

Conversation

@keithrfung

@keithrfung keithrfung commented Oct 29, 2020 •

Copy link
Copy Markdown
Contributor

Issue

Fixes #238

Description

Create methods on logger for add/remove handlers and get all handlers. Expose these in global methods as well on the global instance of LOG.

Open up the get methods for file and stream handlers

Remove the file logger since it now can be added afterward instead of by default.

Testing

  • This can be tested by checking the log output

Checklist

🚨Please review the guidelines for contributing to this repository.

  • 🤔 CONSIDER adding a unit test if your PR resolves an issue.
  • ✅ DO check open PR's to avoid duplicates.
  • ✅ DO keep pull requests small so they can be easily reviewed.
  • ✅ DO build locally before pushing.
  • ✅ DO make sure tests pass.
  • ✅ DO make sure any new changes are documented.
  • ✅ DO make sure not to introduce any compiler warnings.
  • ❌AVOID breaking the continuous integration build.
  • ❌AVOID making significant changes to the overall architecture.

💚Thank you!

@keithrfung keithrfung added the code owner only Only for Code Owner label Oct 29, 2020
@keithrfung
keithrfung force-pushed the feature/open-up-logging branch from c237c9a to 7b5e150 Compare October 29, 2020 21:26
Comment thread src/electionguard/logs.py Resolved

@rkorsak rkorsak left a comment

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 is my fault, but I'm realizing that we can't put this in the __init__ unless we make deeper changes to our singleton approach.

The library uses the shared LOG instance everywhere, and it's initialized in this file with empty arguments.

I think we may just want to expose a method to add a file handler to an existing logger for now. It wouldn't address the optional file/stream handlers, but it gets us moving at least.

Create methods on logger for add/remove handlers and get all handlers. Expose these in global methods as well on the global instance of LOG.

Open up the get methods for file and stream handlers

Remove the file logger since it now can be added afterward instead of by default.
'silent' apparently should be without quotes.
A warning is thrown on lint.
@keithrfung
keithrfung force-pushed the feature/open-up-logging branch from 7b5e150 to f7727ee Compare October 30, 2020 14:37
@keithrfung
keithrfung requested a review from rkorsak October 30, 2020 14:38
Comment thread src/electionguard/logs.py
super(ElectionGuardLog, self).__init__()

self.__logger = logging.getLogger("electionguard")
self.__logger.addHandler(self._get_file_handler())

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.

Note: The file handler is removed. It can now be added at any point, but is not the default.

Comment thread mypy.ini
disallow_untyped_defs = True
ignore_missing_imports = True
follow_imports = "silent"
follow_imports = silent

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.

This was throwing a warning on lint. Apparently it does not need quotes.

@rkorsak rkorsak left a comment

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.

:shipit:

@keithrfung
keithrfung merged commit 932022c into main Oct 30, 2020
@keithrfung
keithrfung deleted the feature/open-up-logging branch October 30, 2020 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code owner only Only for Code Owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🔧 Open up logging to allow different handlers

3 participants