Skip to content

Instantly share code, notes, and snippets.

@briandoll
Created June 4, 2009 18:22
Show Gist options
  • Save briandoll/123755 to your computer and use it in GitHub Desktop.
Save briandoll/123755 to your computer and use it in GitHub Desktop.
# 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