Merge pull request #899 from tcely/patch-6

Clean up debug logs from `process_tasks`
This commit is contained in:
meeb 2025-03-29 01:19:50 +11:00 committed by GitHub
commit 9d3c9c4414
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,12 +19,17 @@ app_logger.addHandler(default_sh)
app_logger.setLevel(logging_level)
class NoWaitingForTasksFilter(logging.Filter):
def filter(self, record):
return 'waiting for tasks' != record.getMessage()
background_task_name = 'background_task.management.commands.process_tasks'
last_part = background_task_name.rsplit('.', 1)[-1]
background_task_formatter = logging.Formatter(
f'%(asctime)s [{last_part}/%(levelname)s] %(message)s'
)
background_task_sh = logging.StreamHandler()
background_task_sh.addFilter(NoWaitingForTasksFilter())
background_task_sh.setFormatter(background_task_formatter)
background_task_sh.setLevel(logging_level)
background_task_logger = logging.getLogger(background_task_name)