Created
June 4, 2009 18:22
-
-
Save briandoll/123755 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment