diff --git a/src/joobq/dead_letter_manager.cr b/src/joobq/dead_letter_manager.cr index 2d6468c..623542a 100644 --- a/src/joobq/dead_letter_manager.cr +++ b/src/joobq/dead_letter_manager.cr @@ -14,7 +14,8 @@ module JoobQ def self.add(job) store.mark_as_dead(job, expires) - Log.info { "Job #{job.id} has been added to the dead letter queue" } + Log.info &.emit("Job added to dead letter queue", + job_id: job.jid, status: job.status, expires: job.expires, retries: job.retries, queue: job.queue) end end end diff --git a/src/joobq/middlewares/retry.cr b/src/joobq/middlewares/retry.cr index 0971594..5564366 100644 --- a/src/joobq/middlewares/retry.cr +++ b/src/joobq/middlewares/retry.cr @@ -39,7 +39,8 @@ module JoobQ delay = (2 ** (job.retries)) * 1000 # Delay in ms # Logic to add the job back to the queue after a delay queue.store.schedule(job, delay, delay_set: RedisStore::FAILED_SET) - Log.info { "Job #{job.id} has been scheduled for retry in #{delay}ms" } + Log.info &.emit("Job has been scheduled for retry", retry_in: delay, + job_id: job.jid, status: job.status, expires: job.expires, retries: job.retries, queue: job.queue) end end end diff --git a/src/joobq/middlewares/throttle.cr b/src/joobq/middlewares/throttle.cr index 30b053d..6ce7ae1 100644 --- a/src/joobq/middlewares/throttle.cr +++ b/src/joobq/middlewares/throttle.cr @@ -28,7 +28,7 @@ module JoobQ elapsed = now - last_job_time sleep_time = min_interval - elapsed - Log.debug { "Throttling #{queue.name} queue. Last job was #{elapsed}ms ago. Sleeping for #{sleep_time}ms" } + Log.debug &.emit("Throttling #{queue.name} queue. Last job was #{elapsed}ms ago. Sleeping for #{sleep_time}ms") if sleep_time > 0 sleep (sleep_time / 1000.0).seconds diff --git a/src/joobq/middlewares/timeout.cr b/src/joobq/middlewares/timeout.cr index aa1e9c2..4188ef1 100644 --- a/src/joobq/middlewares/timeout.cr +++ b/src/joobq/middlewares/timeout.cr @@ -10,8 +10,10 @@ module JoobQ def call(job : Job, queue : BaseQueue, next_middleware : ->) : Nil if job.expired? job.expired! - Log.info { "Job #{job.id} has expired" } + DeadLetterManager.add(job) + Log.info &.emit("Job has expired, added to dead letter queue", + job_id: job.jid, status: job.status, expires: job.expires, retries: job.retries, queue: job.queue) else next_middleware.call end diff --git a/src/joobq/worker.cr b/src/joobq/worker.cr index 7ddd3df..a567372 100644 --- a/src/joobq/worker.cr +++ b/src/joobq/worker.cr @@ -40,7 +40,7 @@ module JoobQ break else if job = @queue.next_job - handle_job job + handle_job job.to_s end end end