@@ -71,17 +71,21 @@ def add_custom_fields(&block)
7171 LogStasher ::CustomFields . add ( *LogStasher . store . keys )
7272 instance_exec ( fields , &block )
7373 end
74- ::ActionController ::Metal . send ( :define_method , :logstasher_add_custom_fields_to_payload , &wrapped_block )
75- ::ActionController ::Base . send ( :define_method , :logstasher_add_custom_fields_to_payload , &wrapped_block )
74+ ::ActiveSupport . on_load ( :action_controller ) do
75+ ::ActionController ::Metal . send ( :define_method , :logstasher_add_custom_fields_to_payload , &wrapped_block )
76+ ::ActionController ::Base . send ( :define_method , :logstasher_add_custom_fields_to_payload , &wrapped_block )
77+ end
7678 end
7779
7880 def add_custom_fields_to_request_context ( &block )
7981 wrapped_block = proc do |fields |
8082 instance_exec ( fields , &block )
8183 LogStasher ::CustomFields . add ( *fields . keys )
8284 end
83- ::ActionController ::Metal . send ( :define_method , :logstasher_add_custom_fields_to_request_context , &wrapped_block )
84- ::ActionController ::Base . send ( :define_method , :logstasher_add_custom_fields_to_request_context , &wrapped_block )
85+ ::ActiveSupport . on_load ( :action_controller ) do
86+ ::ActionController ::Metal . send ( :define_method , :logstasher_add_custom_fields_to_request_context , &wrapped_block )
87+ ::ActionController ::Base . send ( :define_method , :logstasher_add_custom_fields_to_request_context , &wrapped_block )
88+ end
8589 end
8690
8791 def add_default_fields_to_request_context ( request )
0 commit comments