app/controllers/card_controller.rb in wagn-1.14.6 vs app/controllers/card_controller.rb in wagn-1.14.7
- old
+ new
@@ -8,20 +8,22 @@
include Card::Format::Location
include Card::HtmlFormat::Location
include Recaptcha::Verify
+ before_filter :start_performance_logger if Wagn.config.performance_logger
+ after_filter :stop_performance_logger if Wagn.config.performance_logger
+ after_filter :request_logger if Wagn.config.request_logger
+
before_filter :per_request_setup, :except => [:asset]
before_filter :load_id, :only => [ :read ]
before_filter :load_card, :except => [:asset]
before_filter :refresh_card, :only=> [ :create, :update, :delete, :rollback ]
- if Wagn.config.request_logger
- require 'csv'
- after_filter :request_logger
- end
+
+
layout nil
attr_reader :card
@@ -124,30 +126,18 @@
def refresh_card
@card = card.refresh
end
def request_logger
- unless env["REQUEST_URI"] =~ %r{^/files?/}
- log = []
- log << (Card::Env.ajax? ? "YES" : "NO")
- log << env["REMOTE_ADDR"]
- log << Card::Auth.current_id
- log << card.name
- log << action_name
- log << params['view'] || (s = params['success'] and s['view'])
- log << env["REQUEST_METHOD"]
- log << status
- log << env["REQUEST_URI"]
- log << DateTime.now.to_s
- log << env['HTTP_ACCEPT_LANGUAGE'].to_s.scan(/^[a-z]{2}/).first
- log << env["HTTP_REFERER"]
-
- log_dir = (Wagn.paths['request_log'] || Wagn.paths['log']).first
- log_filename = "#{Date.today}_#{Rails.env}.csv"
- File.open(File.join(log_dir,log_filename), "a") do |f|
- f.write CSV.generate_line(log)
- end
- end
+ Wagn::Log::Request.write_log_entry self
+ end
+
+ def start_performance_logger
+ Wagn::Log::Performance.start :method=>env["REQUEST_METHOD"], :message=>env["PATH_INFO"]
+ end
+
+ def stop_performance_logger
+ Wagn::Log::Performance.stop
end
protected
def ajax?