aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/logging.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activejob/lib/active_job/logging.rb')
-rw-r--r--activejob/lib/active_job/logging.rb18
1 files changed, 16 insertions, 2 deletions
diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb
index 54774db601..605057d1e8 100644
--- a/activejob/lib/active_job/logging.rb
+++ b/activejob/lib/active_job/logging.rb
@@ -1,3 +1,4 @@
+require 'active_support/core_ext/hash/transform_values'
require 'active_support/core_ext/string/filters'
require 'active_support/tagged_logging'
require 'active_support/logger'
@@ -25,7 +26,7 @@ module ActiveJob
end
end
- before_enqueue do |job|
+ after_enqueue do |job|
if job.scheduled_at
ActiveSupport::Notifications.instrument "enqueue_at.active_job",
adapter: job.class.queue_adapter, job: job
@@ -87,12 +88,25 @@ module ActiveJob
def args_info(job)
if job.arguments.any?
' with arguments: ' +
- job.arguments.map { |arg| arg.try(:to_global_id).try(:to_s) || arg.inspect }.join(', ')
+ job.arguments.map { |arg| format(arg).inspect }.join(', ')
else
''
end
end
+ def format(arg)
+ case arg
+ when Hash
+ arg.transform_values { |value| format(value) }
+ when Array
+ arg.map { |value| format(value) }
+ when GlobalID::Identification
+ arg.to_global_id rescue arg
+ else
+ arg
+ end
+ end
+
def scheduled_at(event)
Time.at(event.payload[:job].scheduled_at).utc
end