Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a default logger in bin/jobs #423

Open
djfpaagman opened this issue Nov 21, 2024 · 3 comments
Open

Add a default logger in bin/jobs #423

djfpaagman opened this issue Nov 21, 2024 · 3 comments

Comments

@djfpaagman
Copy link

djfpaagman commented Nov 21, 2024

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
Copy link
Author

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
Copy link
Member

rosa commented Nov 21, 2024

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 🤔

@djfpaagman
Copy link
Author

hi @rosa!

Indeed that's how it's happening right now, it's just not the expected behavior for me.

I run my app through foreman with a Procfile like so:

web: bin/rails s
vite: bin/vite dev
jobs: bin/jobs

By default, the logs from Solid Queue are not visible anywhere and only go to development.log.

If I run Solid Queue via the Puma plugin I do get all the logs in my web process (as they then share the rails logger?).

If I configure the logger explicitly I only get the logs from Solid Queue itself (the ones defined in https://github.com/rails/solid_queue/blob/main/lib/solid_queue/log_subscriber.rb), but not the AR logs.

I would expect all the logs from a particular process to be sent to the output of that process when configured to log there. And I think it would make sense to do that by default, at least in development environments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants