lib/timber/events/controller_call.rb in timber-1.1.14 vs lib/timber/events/controller_call.rb in timber-2.0.0
- old
+ new
@@ -2,12 +2,12 @@
module Events
# The controller call event tracks controller invocations. For example, this line in Rails:
#
# Processing by PagesController#home as HTML
#
- # @note This event should be installed automatically through probes,
- # such as the {Probes::ActionControllerLogSubscriber} probe.
+ # @note This event should be installed automatically through integrations,
+ # such as the {Integrations::ActionController::LogSubscriber} integration.
class ControllerCall < Timber::Event
attr_reader :controller, :action, :params, :format
def initialize(attributes)
@controller = attributes[:controller] || raise(ArgumentError.new(":controller is required"))
@@ -15,11 +15,11 @@
@params = attributes[:params]
@format = attributes[:format]
end
def to_hash
- {controller: controller, action: action}
+ {controller: controller, action: action, params_json: params_json}
end
alias to_h to_hash
def as_json(_options = {})
{:server_side_app => {:controller_call => to_hash}}
@@ -33,8 +33,17 @@
if !params.nil? && params.length > 0
message << "\n Parameters: #{params.inspect}"
end
message
end
+
+ private
+ def params_json
+ @params_json ||= if params.nil? || params == {}
+ nil
+ else
+ params.to_json
+ end
+ end
end
end
end
\ No newline at end of file