lib/logstasher.rb in logstasher-0.4.7 vs lib/logstasher.rb in logstasher-0.4.8

- old
+ new

@@ -4,11 +4,11 @@ require 'active_support/core_ext/string/inflections' require 'active_support/ordered_options' module LogStasher extend self - attr_accessor :logger, :enabled + attr_accessor :logger, :enabled, :log_controller_parameters def remove_existing_log_subscriptions ActiveSupport::LogSubscriber.log_subscribers.each do |subscriber| case subscriber when ActionView::LogSubscriber @@ -31,12 +31,15 @@ end def add_default_fields_to_payload(payload, request) payload[:ip] = request.remote_ip payload[:route] = "#{request.params[:controller]}##{request.params[:action]}" - payload[:parameters] = payload[:params].except(*ActionController::LogSubscriber::INTERNAL_PARAMS) - self.custom_fields += [:ip, :route, :parameters] + self.custom_fields += [:ip, :route] + if self.log_controller_parameters + payload[:parameters] = payload[:params].except(*ActionController::LogSubscriber::INTERNAL_PARAMS) + self.custom_fields += [:parameters] + end end def add_custom_fields(&block) ActionController::Metal.send(:define_method, :logtasher_add_custom_fields_to_payload, &block) ActionController::Base.send(:define_method, :logtasher_add_custom_fields_to_payload, &block) @@ -50,9 +53,10 @@ self.suppress_app_logs(app) LogStasher::RequestLogSubscriber.attach_to :action_controller self.logger = app.config.logstasher.logger || new_logger("#{Rails.root}/log/logstash_#{Rails.env}.log") self.logger.level = app.config.logstasher.log_level || Logger::WARN self.enabled = true + self.log_controller_parameters = !! app.config.logstasher.log_controller_parameters end def suppress_app_logs(app) if configured_to_suppress_app_logs?(app) require 'logstasher/rails_ext/rack/logger'