Skip to content

Commit

Permalink
Logging test
Browse files Browse the repository at this point in the history
  • Loading branch information
k-macmillan committed Nov 29, 2024
1 parent 76a8231 commit bce23cf
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/celery/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ def filter(self, record):
@task_prerun.connect
def add_id_to_logger(task_id, task, *args, **kwargs):
logger = logging.getLogger('celery.task')
logger.info('this is a prerun test!')
request_id = kwargs.get('notification_id', task_id)
logger.addHandler(CeleryRequestIdFilter(request_id, f'celery-{request_id}'))


@task_postrun.connect
def id_cleanup_logger(task_id, task, *args, **kwargs):
logger = logging.getLogger('celery.task')
logger.info('this is a postrun test!')
request_id = kwargs.get('notification_id', task_id)
for handler in logger.handlers:
if handler.name == f'celery-{request_id}':
Expand Down

0 comments on commit bce23cf

Please sign in to comment.