Sha256: e38166f77653516d4595d3f064afce9c964b9d5128396a8d3ac336cf25a7a6b4
Contents?: true
Size: 1.27 KB
Versions: 2
Compression:
Stored size: 1.27 KB
Contents
module ActiveRecord module SqlAnalyzer class RedactedLogger < CompactLogger def filter_event(event) # Determine if we're doing extended tracing or only the first calls = event.delete(:calls).map do |call| {sql: filter_sql(call[:sql]), caller: filter_caller(call[:caller])} end # De-duplicate redacted calls to avoid many transactions with looping "N+1" queries. calls.uniq! event[:sql] = calls.map { |call| call[:sql] } event[:caller] = calls.map { |call| call[:caller] }.join(';; ') if event[:sql].size == 1 event[:sql] = event[:sql].first else event[:sql] = event[:sql].join('; ') + ';' end end def filter_caller(kaller) kaller = if config[:ambiguous_tracers].any? { |regex| kaller.first =~ regex } kaller[0, config[:ambiguous_backtrace_lines]].join(", ") else kaller.first end config[:backtrace_redactors].each do |redactor| kaller.gsub!(redactor.search, redactor.replace) end kaller end def filter_sql(sql) config[:sql_redactors].each do |redactor| sql.gsub!(redactor.search, redactor.replace) end sql end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
active_record-sql_analyzer-0.2.1 | lib/active_record/sql_analyzer/redacted_logger.rb |
active_record-sql_analyzer-0.2.0 | lib/active_record/sql_analyzer/redacted_logger.rb |