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

fix logging for workers #517

Merged
merged 7 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/jobs/send_reset_password_email_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ class SendResetPasswordEmailJob < ApplicationJob
def perform(email, os, browser)
person = Person.find_by_email(email)

Rails.logger.info "Sending reset password email to #{email} from #{os} with #{browser}"

if person&.user # make sure the user exists (i.e. user has not become a tombstone)
PasswordMailer.with(person: person, os: os, browser: browser).reset.deliver_now
end
Expand Down
14 changes: 13 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,21 @@
config.action_controller.raise_on_missing_callback_actions = true

# Since most people will not set the variable, polling will not be logged
config.solid_queue.silence_polling = ENV["SOLID_QUEUE_LOG_POLLING_ON"] != "false"
# anything but explicitly false
log_polling = ENV["SOLID_QUEUE_LOG_POLLING_ON"] != "false"
config.solid_queue.silence_polling = log_polling # NOTE: this is backwards, true means silence
# config.solid_queue.process_heartbeat_interval = 3.seconds

config.web_console.permissions = ["192.168.0.0/16", "172.17.0.0/16"]

config.hosts << ENV["DEV_HOST"] if ENV["DEV_HOST"].present?

config.log_level = :debug
stdout_logger = ActiveSupport::Logger.new(STDOUT)
tagged_logger = ActiveSupport::TaggedLogging.new(stdout_logger)

config.log_tags = [ :request_id ]
config.logger = tagged_logger


end
17 changes: 17 additions & 0 deletions config/initializers/solid_queue_extension.rb
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to get a PR in for solidqueue to make this an official option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module CustomProcess
def heartbeat
# only silence if explicitly set to not log (default to logging)
# true or not set (or anything else) means log, false means silence
silence_heartbeat = ENV["SOLID_QUEUE_LOG_HEARTBEAT_ON"] == "false"

if silence_heartbeat && ActiveRecord::Base.logger
ActiveRecord::Base.logger.silence { super }
else
super
end
end
end

Rails.application.config.after_initialize do
SolidQueue::Process.send(:prepend, CustomProcess)
end
Loading