39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/factory_bot_instruments/tracing.rb', line 39
def self.sql_tracer(active)
return yield unless active
begin
stdout_log = Logger.new($stdout)
stdout_log.formatter = proc do |severity, datetime, progname, msg|
depth = "| " * ($FACTORY_BOT_INSTRUMENTS_TRACING_DEPTH - 1)
msg = FactoryBotInstruments::TracingHelpers.uncolorize(msg)
msg = msg.strip
msg = msg.gsub(/^SQL /, "")
"#{depth}| \e[36m#{msg}\e[0m\n"
end
standard_logger = ActiveRecord::Base.logger
ActiveRecord::Base.logger = stdout_log
yield
ensure
ActiveRecord::Base.logger = standard_logger
end
end
|