-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 🔧 Open up logging 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. * ✅ MyPy correction to silent 'silent' apparently should be without quotes. A warning is thrown on lint. * ✅Add tests for logs
- Loading branch information
1 parent
95e122b
commit 932022c
Showing
3 changed files
with
109 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from unittest import TestCase | ||
|
||
from electionguard.logs import ( | ||
get_stream_handler, | ||
log_add_handler, | ||
log_remove_handler, | ||
log_handlers, | ||
log_debug, | ||
log_error, | ||
log_info, | ||
log_warning, | ||
) | ||
|
||
|
||
class TestLogs(TestCase): | ||
def test_log_methods(self): | ||
# Arrange | ||
message = "test log message" | ||
|
||
# Act | ||
log_debug(message) | ||
log_error(message) | ||
log_info(message) | ||
log_warning(message) | ||
|
||
def test_log_handlers(self): | ||
# Arrange | ||
|
||
# Act | ||
handlers = log_handlers() | ||
|
||
# Assert | ||
self.assertEqual(len(handlers), 1) | ||
|
||
# Act | ||
log_remove_handler(handlers[0]) | ||
empty_handlers = log_handlers() | ||
|
||
# Assert | ||
self.assertEqual(len(empty_handlers), 0) | ||
|
||
# Act | ||
log_add_handler(get_stream_handler()) | ||
added_handlers = log_handlers() | ||
|
||
# Assert | ||
self.assertEqual(len(added_handlers), 1) |