Skip to content

Commit

Permalink
fix logging for workers (#517)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlvallelonga authored Oct 18, 2024
1 parent eeaec80 commit 07610fd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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
10 changes: 9 additions & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,17 @@
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.web_console.permissions = ["192.168.0.0/16", "172.17.0.0/16"]

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

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
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

0 comments on commit 07610fd

Please sign in to comment.