diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2014-12-05 11:05:15 -0200 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2014-12-05 11:05:15 -0200 |
commit | ad4935f12745e36c70f7fe15e920371a7f107f2a (patch) | |
tree | 75bbb18243b4b10f30908cc4fec207f72b1cb7f8 /activejob | |
parent | 95ddfc4e5840ca88e559157ca105e0042eb5942b (diff) | |
parent | e2fffbff98a3c60d3efb8d98a3554bea28dca532 (diff) | |
download | rails-ad4935f12745e36c70f7fe15e920371a7f107f2a.tar.gz rails-ad4935f12745e36c70f7fe15e920371a7f107f2a.tar.bz2 rails-ad4935f12745e36c70f7fe15e920371a7f107f2a.zip |
Merge pull request #17817 from aripollak/hide-activejob-args
GlobalID objects are logged by their URI, not #inspect on the object, to prevent logging private data
Diffstat (limited to 'activejob')
-rw-r--r-- | activejob/lib/active_job/logging.rb | 7 | ||||
-rw-r--r-- | activejob/test/cases/logging_test.rb | 8 |
2 files changed, 14 insertions, 1 deletions
diff --git a/activejob/lib/active_job/logging.rb b/activejob/lib/active_job/logging.rb index 21d2fda3ff..cd29e6908e 100644 --- a/activejob/lib/active_job/logging.rb +++ b/activejob/lib/active_job/logging.rb @@ -85,7 +85,12 @@ module ActiveJob end def args_info(job) - job.arguments.any? ? " with arguments: #{job.arguments.map(&:inspect).join(", ")}" : "" + if job.arguments.any? + ' with arguments: ' + + job.arguments.map { |arg| arg.try(:to_global_id).try(:to_s) || arg.inspect }.join(', ') + else + '' + end end def scheduled_at(event) diff --git a/activejob/test/cases/logging_test.rb b/activejob/test/cases/logging_test.rb index 3d4e561117..745aedb6bd 100644 --- a/activejob/test/cases/logging_test.rb +++ b/activejob/test/cases/logging_test.rb @@ -65,6 +65,14 @@ class AdapterTest < ActiveSupport::TestCase LoggingJob.queue_name = original_queue_name end + def test_globalid_parameter_logging + person = Person.new(123) + LoggingJob.perform_later person + assert_match(%r{Enqueued.*gid://aj/Person/123}, @logger.messages) + assert_match(%r{Dummy, here is it: #<Person:.*>}, @logger.messages) + assert_match(%r{Performing.*gid://aj/Person/123}, @logger.messages) + end + def test_enqueue_job_logging HelloJob.perform_later "Cristian" assert_match(/Enqueued HelloJob \(Job ID: .*?\) to .*?:.*Cristian/, @logger.messages) |