Skip to content

Commit

Permalink
Remove "Failed to decrypt" error log from processor_modify_personal_i…
Browse files Browse the repository at this point in the history
…nfo.py
  • Loading branch information
purplesmoke05 committed Jul 31, 2024
1 parent f889b50 commit 54450cc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions batch/processor_modify_personal_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"""

import asyncio
import logging
import sys
from asyncio import Event
from typing import Sequence, Set
Expand Down Expand Up @@ -58,6 +59,20 @@
LOG = batch_log.get_logger(process_name=process_name)


class SupressDecryptFailedLogFilter(logging.Filter):
def filter(self, record: logging.LogRecord):
if (
record.levelname == "ERROR"
and isinstance(record.msg, str)
and "Failed to decrypt" in record.msg
):
return False
return True


LOG.addFilter(SupressDecryptFailedLogFilter())


class Processor:
def __init__(self, is_shutdown: Event):
self.is_shutdown = is_shutdown
Expand Down
2 changes: 1 addition & 1 deletion tests/batch/test_processor_modify_personal_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ async def test_normal_1(self, processor, db, caplog: pytest.LogCaptureFixture):
await processor.process()

# assertion(Run 3rd)
assert "Failed to decrypt" in caplog.text
assert "Failed to decrypt" not in caplog.text
assert (
"background",
logging.INFO,
Expand Down

0 comments on commit 54450cc

Please sign in to comment.