bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

Python: Add basic logging, remove print statements, ...

Open AIexanderDicke opened this issue 9 months ago • 1 comments

At the moment, the python library has no logging. Errors are simply printed to stdout (e.g. here or here). This makes it very difficult to monitor an application that uses BullMQ.

Some examples of logs to add (always assuming logger = logging.getLogger(__name__)):

  1. Remove the printing of exceptions and instead log on error level. For example, change this line to something like
logging.error(f"Error processing job {repr(err)}")

Even better might be something more informative like

logging.error(f"Error processing Job (Worker: `{self.name}`, Job ID: `{job.id}`, Queue name: {job.queue.name}): {repr(err)})
  1. Add basic job logging on info (or maybe debug) level, e.g. by adding something like
logger.info(f"Processing Job (Job ID: `{job.id}`, Queue name: {job.queue.name})")

to the Worker.processJob method.

  1. Add logs for adding jobs to a queue, maybe something along the lines of
logger.info(f"Job added to the queue `{self.name}` (Job ID: {job_id})") 

I would be happy to implement this, if there are no objections to these changes!

AIexanderDicke avatar May 18 '24 10:05 AIexanderDicke