-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add optional project_name field to JSON log output
- Loading branch information
Showing
4 changed files
with
37 additions
and
3 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
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,18 @@ | ||
from pythonjsonlogger import jsonlogger | ||
|
||
from codemodder.logging import OutputFormat, configure_logger | ||
|
||
|
||
def test_json_logger(mocker): | ||
basic_config = mocker.patch("logging.basicConfig") | ||
configure_logger(False, OutputFormat.JSON, "test-project") | ||
assert basic_config.call_count == 1 | ||
assert basic_config.call_args[1]["format"] == "%(message)s" | ||
assert isinstance( | ||
basic_config.call_args[1]["handlers"][0].formatter, | ||
jsonlogger.JsonFormatter, | ||
) | ||
assert ( | ||
basic_config.call_args[1]["handlers"][0].formatter.project_name | ||
== "test-project" | ||
) |