bullmq icon indicating copy to clipboard operation
bullmq copied to clipboard

Is there a way to just add timestamps on job log entries ?

Open paulpascal opened this issue 8 months ago • 0 comments

Is your feature request related to a problem? Please describe.

On my current project I use bullmq, to queue jobs needed to handle heavy cli execution, it then requires me sometime to log directly into the job logs.

To be able for an admin, to do a better followup, We had to add the current date to the log as bellow:

const result = await this.executeSomeCommand(jobData);
    if (!result.success) {
      job.log(`[${new Date().toISOString()}]: ${result.message}`);
      // ...
      throw new Error(errorMessage);
 }

and else where, I may be logging also some details like (job postponement):

await job.moveToDelayed(DELAY_IN_MILLIS, processingToken);
const retryMessage = `Job ${job.id} postponed until ${retryTimeFormatted}.  Reason was ....`;
job.log(`[${new Date().toISOString()}]: ${retryMessage}`);

Describe the solution you'd like

Make job.log consider the current time when saving a given log.

paulpascal avatar Jun 05 '24 00:06 paulpascal