lib/neo4j/railtie.rb in neo4j-3.0.0.alpha.11 vs lib/neo4j/railtie.rb in neo4j-3.0.0.rc.2

- old
+ new

@@ -1,5 +1,7 @@ +require 'active_support/notifications' + module Neo4j class Railtie < ::Rails::Railtie config.neo4j = ActiveSupport::OrderedOptions.new # Add ActiveModel translations to the I18n load_path @@ -64,8 +66,18 @@ cfg.sessions.each do |session_opts| Neo4j::Railtie.open_neo4j_session(session_opts) end Neo4j::Config.setup.merge!(cfg.to_hash) + + clear = "\e[0m" + red = "\e[31m" + yellow = "\e[33m" + cyan = "\e[36m" + + ActiveSupport::Notifications.subscribe('neo4j.cypher_query') do |name, start, finish, id, payload| + ms = (finish - start) * 1000 + Rails.logger.info " #{cyan}#{payload[:context]}#{clear} #{yellow}#{ms.round}ms#{clear} #{payload[:cypher]}" + (payload[:params].size > 0 ? ' | ' + payload[:params].inspect : '') + end end end end