-
Notifications
You must be signed in to change notification settings - Fork 103
#739 Logging #749
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
#739 Logging #749
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d0b525c
Better error logging during ballot decryption
lprichar 92b7b03
# per RC 8/15/22 log errors and continue processing even if it makes …
lprichar 78e0820
Ability to set the log level in logger for the stream handler
lprichar dcd0b9f
Combine EG logging with eel logging
lprichar c94126e
cache clean in dockerfile
lprichar db7a769
fix issue with recovering during ballot parsing errors
lprichar e08117a
log to file
lprichar 287c8ba
Use date in file name so that when run on single machine containers d…
lprichar 101daf0
Log stack traces
lprichar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,59 @@ | ||
| from datetime import datetime | ||
| import logging | ||
| from os import path, makedirs | ||
| from typing import Any | ||
| from electionguard.logs import ( | ||
| get_file_handler, | ||
| log_critical, | ||
| log_debug, | ||
| log_error, | ||
| log_info, | ||
| log_warning, | ||
| LOG, | ||
| ) | ||
| from electionguard_gui.services.directory_service import get_data_dir | ||
| from electionguard_gui.services.service_base import ServiceBase | ||
|
|
||
|
|
||
| class EelLogService(ServiceBase): | ||
| """A facade for logging. Currently this simply writes to the console without using log levels, but | ||
| this may eventually be used to log to a file or database.""" | ||
|
|
||
| # pylint: disable=no-self-use | ||
| def _log(self, level: str, message: str) -> None: | ||
| print(f"{datetime.now()} {level} {message}") | ||
| def __init__(self) -> None: | ||
| LOG.set_stream_log_level(logging.DEBUG) | ||
| file_dir = path.join(get_data_dir(), "logs") | ||
| makedirs(file_dir, exist_ok=True) | ||
| now = datetime.now().strftime("%Y-%m-%d-%H-%M-%S-%f") | ||
| file_name = path.join(file_dir, f"electionguard-{now}.log") | ||
| LOG.add_handler(get_file_handler(logging.DEBUG, file_name)) | ||
|
|
||
| def trace(self, message: str) -> None: | ||
| def trace(self, message: str, *args: Any, **kwargs: Any) -> None: | ||
| pass | ||
|
|
||
| def debug(self, message: str) -> None: | ||
| self._log("DEBUG", message) | ||
| # pylint: disable=no-self-use | ||
| def debug(self, message: str, *args: Any, **kwargs: Any) -> None: | ||
| log_debug(message, *args, **kwargs) | ||
|
|
||
| def info(self, message: str) -> None: | ||
| self._log("INFO ", message) | ||
| # pylint: disable=no-self-use | ||
| def info(self, message: str, *args: Any, **kwargs: Any) -> None: | ||
| log_info(message, *args, **kwargs) | ||
|
|
||
| def warn(self, message: str) -> None: | ||
| self._log("WARN ", message) | ||
| # pylint: disable=no-self-use | ||
| def warn(self, message: str, *args: Any, **kwargs: Any) -> None: | ||
| log_warning(message, *args, **kwargs) | ||
|
|
||
| def error(self, e: Exception) -> None: | ||
| self._log("ERROR", str(e)) | ||
| # pylint: disable=no-self-use | ||
| def error(self, message: str, exception: Exception) -> None: | ||
| log_error( | ||
| f"{message} '{exception}'", | ||
| exc_info=1, | ||
| extra={"exception": exception}, | ||
| ) | ||
|
|
||
| def fatal(self, message: str) -> None: | ||
| self._log("FATAL", message) | ||
| # pylint: disable=no-self-use | ||
| def fatal(self, message: str, exception: Exception) -> None: | ||
| log_critical( | ||
| f"{message} '{str(exception)}'", | ||
| exc_info=1, | ||
| extra={"exception": exception}, | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.