lib/logstasher.rb in logstasher-0.2.2 vs lib/logstasher.rb in logstasher-0.2.4
- old
+ new
@@ -37,10 +37,11 @@
s+="#{k}=#{v}\n"}
self.custom_fields += [:ip, :route, :parameters]
end
def self.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)
end
def self.setup(app)
app.config.action_dispatch.rack_cache[:verbose] = false if app.config.action_dispatch.rack_cache
@@ -50,21 +51,20 @@
self.suppress_app_logs(app)
LogStasher::RequestLogSubscriber.attach_to :action_controller
self.logger = app.config.logstasher.logger || Logger.new("#{Rails.root}/log/logstash_#{Rails.env}.log")
self.logger.level = app.config.logstasher.log_level || Logger::WARN
self.enabled = true
- self.custom_fields = []
end
def self.suppress_app_logs(app)
if app.config.logstasher.supress_app_log.nil? || app.config.logstasher.supress_app_log
require 'logstasher/rails_ext/rack/logger'
LogStasher.remove_existing_log_subscriptions
end
end
def self.custom_fields
- Thread.current[:logstasher_custom_fields]
+ Thread.current[:logstasher_custom_fields] ||= []
end
def self.custom_fields=(val)
Thread.current[:logstasher_custom_fields] = val
end