Class: Sequel::Database

Inherits:
Object
  • Object
show all
Defined in:
lib/sequel_rails/sequel/database/active_support_notification.rb

Instance Method Summary collapse

Instance Method Details

#log_connection_yield(sql, conn, args = nil) ⇒ Object



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

#log_yield(sql, args = nil, &block) ⇒ Object



27
28
29
# File 'lib/sequel_rails/sequel/database/active_support_notification.rb', line 27

def log_yield(sql, args = nil, &block)
  log_connection_yield(sql, nil, args, &block)
end