5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/trim_blobs/active_record/connection_adapters/abstract_adapter.rb', line 5
def log_with_blobs_trimmed(sql, name = "SQL", binds = [], statement_name = nil)
if sql
sql = sql.gsub(/'\\x((?:[0-9a-f]{2})+)'/) do |blob|
(blob.size > 32) ? "'\\x#{$1[0,32]}... (TRIMMED #{blob.size} hexadecimal digits)'" : $&
end
end
if statement_name
log_without_blobs_trimmed(sql, name, binds, statement_name){ yield }
else
log_without_blobs_trimmed(sql, name, binds){ yield }
end
end
|