briandoll (owner)

Revisions

gist: 123755 Download_button fork
public
Public Clone URL: git://gist.github.com/123755.git
Embed All Files: show embed
add_caller_info_to_sql_logging.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# From Alex Chaffee
# http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour
# Add caller line number to sql logging
module ActiveRecord
  module ConnectionAdapters
    class AbstractAdapter
      def log_info(sql, name, ms)
        if @logger && @logger.debug?
          c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__)/i}
          c.gsub!("#{File.expand_path(File.dirname(RAILS_ROOT))}/", '') if defined?(RAILS_ROOT)
          name = '%s (%.1fms) %s' % [name || 'SQL', ms, c]
          @logger.debug(format_log_entry(name, sql.squeeze(' ')))
        end
      end
    end
  end
end