So Celery is a super great library but its documentation for the logging section isn't the best, which bring me here to request for assistance.
My Script as of now is as so (well in summary):
import logging
from celery import Celery
from celery.utils.log import get_logger
from task import process
import config
logger = get_logger(__name__)
timber_handler = timber.TimberHandler(api_key=config.key,
level=logging.INFO)
logger.addHandler(timber_handler)
app = Celery('task',
broker=config.url,
backend='rpc://')
@app.task
def run_task():
status = get_status() # get alive or dead status
if status == 1:
logger.info("Task is running")
process()
@app.on_after_configure.connect
def task_periodic(**kwargs):
app.add_periodic_task(2.0, run_task.s(), name="Run Constantly")
# More tasks
The process function in the tasks.py file is very basic function hitting up APIs and DBs for some info and I want to be able to log that to a logger (timber.io) which attaches to the python logging library and is an online storage for logs.
However, my major issue is that the logs are getting sent to stdout and not to the timber logs. I have looked at celery.signals but the documentation isn't great. Any assistance here would be greatly appreciated. Thank you.