Created
August 23, 2009 11:39
-
-
Save kares/173245 to your computer and use it in GitHub Desktop.
trim blobs from ActiveRecord's log
This file contains 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
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