Skip to content

Instantly share code, notes, and snippets.

@JackDanger
Created May 24, 2009 06:32
Show Gist options
  • Save JackDanger/116987 to your computer and use it in GitHub Desktop.
Save JackDanger/116987 to your computer and use it in GitHub Desktop.
# from: http://pivotallabs.com/users/alex/blog/articles/865-monkey-patch-du-jour
module ActiveRecord
module ConnectionAdapters
class AbstractAdapter
def log_info(sql, name, ms)
if @logger && @logger.debug?
@logger.debug("#{sql}, #{name}, #{ms}")
c = caller.detect{|line| line !~ /(activerecord|active_support|__DELEGATION__|\/lib\/|\/vendor\/plugins|\/vendor\/gems)/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