Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
add date message
Browse files Browse the repository at this point in the history
  • Loading branch information
malmans2 committed Mar 28, 2024
1 parent 8369626 commit 1c3d97a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions cads_api_client/processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def log_messages(self) -> None:
for message in messages:
if not (content := message.get("content")):
continue
if date := message.get("date"):
content = f"[{date}] {content}"
severity = message.get("severity", "notset").upper()
level = logging.getLevelName(severity)
logger.log(level if isinstance(level, int) else 20, content)
Expand Down
14 changes: 11 additions & 3 deletions tests/test_10_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"content": "This is a warning message",
},
{
"date": "2023-12-12T13:00:00",
"date": "2023-12-12T14:00:00",
"severity": "success",
"content": "This is a success message",
},
Expand Down Expand Up @@ -349,8 +349,16 @@ def test_log_messages(caplog: pytest.LogCaptureFixture) -> None:
remote.wait_on_result()

assert caplog.record_tuples == [
("cads_api_client.processing", 30, "This is a warning message"),
("cads_api_client.processing", 20, "This is a success message"),
(
"cads_api_client.processing",
30,
"[2023-12-12T13:00:00] This is a warning message",
),
(
"cads_api_client.processing",
20,
"[2023-12-12T14:00:00] This is a success message",
),
(
"cads_api_client.processing",
10,
Expand Down

0 comments on commit 1c3d97a

Please sign in to comment.