rails / solid_queue

Database-backed Active Job backend
MIT License
1.95k stars 130 forks source link

Add a default logger in bin/jobs #423

Open djfpaagman opened 10 hours ago

djfpaagman commented 10 hours ago

Hello,

I'm wondering if it's a good idea to add a default logger in the generated bin/jobs file. I use it in development and was expecting at least some log output from it, but it's entirely silent.

What works for me locally is adding:

SolidQueue.logger = ActiveSupport::Logger.new($stdout)

do you feel like adding this makes sense? I'll happily create a PR if so :)

I'm not sure if it's ok to rely on Active Support like this directly, so suggestions are also welcome.

djfpaagman commented 7 hours ago

Hmm I just noticed if I define the logger like that, the related AR query logs still only end up in log/development.log 🤔

If I run it in puma plugin mode I do get them all together, but I guess that makes sense as they will share the same logger then.

rosa commented 3 hours ago

Hey @djfpaagman! By default, Solid Queue uses Rails's logger, which in development writes to log/development.log, so that's where you'll find the logs from bin/jobs. If you initialize it to:

ActiveSupport::Logger.new($stdout)

the queries logged by Active Record would still go to the logger configured in ActiveRecord::Base.logger, which I think should be Rails.logger too, so log/development.log 🤔