Skip to content

Commit 07610fd

Browse files
authored
fix logging for workers (#517)
1 parent eeaec80 commit 07610fd

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

app/jobs/send_reset_password_email_job.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class SendResetPasswordEmailJob < ApplicationJob
44
def perform(email, os, browser)
55
person = Person.find_by_email(email)
66

7+
Rails.logger.info "Sending reset password email to #{email} from #{os} with #{browser}"
8+
79
if person&.user # make sure the user exists (i.e. user has not become a tombstone)
810
PasswordMailer.with(person: person, os: os, browser: browser).reset.deliver_now
911
end

config/environments/development.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,17 @@
7575
config.action_controller.raise_on_missing_callback_actions = true
7676

7777
# Since most people will not set the variable, polling will not be logged
78-
config.solid_queue.silence_polling = ENV["SOLID_QUEUE_LOG_POLLING_ON"] != "false"
78+
# anything but explicitly false
79+
log_polling = ENV["SOLID_QUEUE_LOG_POLLING_ON"] != "false"
80+
config.solid_queue.silence_polling = log_polling # NOTE: this is backwards, true means silence
7981

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

8284
config.hosts << ENV["DEV_HOST"] if ENV["DEV_HOST"].present?
85+
86+
stdout_logger = ActiveSupport::Logger.new(STDOUT)
87+
tagged_logger = ActiveSupport::TaggedLogging.new(stdout_logger)
88+
89+
config.log_tags = [ :request_id ]
90+
config.logger = tagged_logger
8391
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module CustomProcess
2+
def heartbeat
3+
# only silence if explicitly set to not log (default to logging)
4+
# true or not set (or anything else) means log, false means silence
5+
silence_heartbeat = ENV["SOLID_QUEUE_LOG_HEARTBEAT_ON"] == "false"
6+
7+
if silence_heartbeat && ActiveRecord::Base.logger
8+
ActiveRecord::Base.logger.silence { super }
9+
else
10+
super
11+
end
12+
end
13+
end
14+
15+
Rails.application.config.after_initialize do
16+
SolidQueue::Process.send(:prepend, CustomProcess)
17+
end

0 commit comments

Comments
 (0)