Sha256: 0b219a7469183a7aa38b6a386b9851a3c2c4cd29d8370fcb3a4784082192b5f7

Contents?: true

Size: 817 Bytes

Versions: 13

Compression:

Stored size: 817 Bytes

Contents

require 'sequel/database/logging'
require 'active_support/notifications'

module Sequel
  class Database

    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

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sequel-rails-1.2.3 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.2.2 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.2.1 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.2.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.1.1 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.1.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.0.1 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-1.0.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.9.17 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.9.16 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.9.15 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.9.14 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.9.13 lib/sequel_rails/sequel/database/active_support_notification.rb