2021-02-07 03:29:24 +01:00
|
|
|
# standard imports
|
|
|
|
import logging
|
|
|
|
import time
|
|
|
|
|
|
|
|
# third-party imports
|
|
|
|
import celery
|
|
|
|
|
|
|
|
celery_app = celery.current_app
|
|
|
|
logg = celery_app.log.get_default_logger()
|
2022-01-04 17:51:02 +01:00
|
|
|
local_logg = logging.getLogger()
|
2021-02-07 03:29:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
@celery_app.task
|
2021-08-29 11:55:47 +02:00
|
|
|
def log(message, recipient):
|
2021-02-07 03:29:24 +01:00
|
|
|
"""
|
2021-08-29 11:55:47 +02:00
|
|
|
|
2021-02-07 03:29:24 +01:00
|
|
|
:param message:
|
|
|
|
:type message:
|
2021-08-29 11:55:47 +02:00
|
|
|
:param recipient:
|
|
|
|
:type recipient:
|
2021-02-07 03:29:24 +01:00
|
|
|
:return:
|
|
|
|
:rtype:
|
|
|
|
"""
|
|
|
|
timestamp = time.time()
|
|
|
|
log_string = f'[{timestamp}] {__name__} message to {recipient}: {message}'
|
|
|
|
logg.info(log_string)
|
|
|
|
local_logg.info(log_string)
|