Skip to content

Instantly share code, notes, and snippets.

@kares
Created August 23, 2009 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kares/173245 to your computer and use it in GitHub Desktop.
Save kares/173245 to your computer and use it in GitHub Desktop.
trim blobs from ActiveRecord's log
ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
def log_with_blobs_trimmed(sql, name, &block)
sql = sql.gsub(/x'([^']+)'/) do |blob|
blob.size > 32 ? "x'#{$1[0,32]}... (#{blob.size} bytes)'" : $0
end if sql
log_without_blobs_trimmed(sql, name, &block)
end
alias_method_chain :log, :blobs_trimmed
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment