7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/sequel_rails/sequel/database/active_support_notification.rb', line 7
def log_connection_yield(sql, conn, args=nil)
sql_for_log = "#{connection_info(conn) if conn && log_connection_info}#{sql}#{"; #{args.inspect}" if args}"
start = Time.now
begin
::ActiveSupport::Notifications.instrument(
'sql.sequel',
:sql => sql,
:name => self.class,
:binds => args
) do
yield
end
rescue => e
log_exception(e, sql_for_log) unless @loggers.empty?
raise
ensure
log_duration(Time.now - start, sql_for_log) unless e || @loggers.empty?
end
end
|