Sha256: 03a370f824b6c8f94b9e116ff04c3825f5ed292cbd803a0deed34a79b5d9875d

Contents?: true

Size: 643 Bytes

Versions: 9

Compression:

Stored size: 643 Bytes

Contents

require "sequel/database/logging"
require "active_support/notifications"

module Sequel
  class Database

    def log_yield(sql, args=nil)
      sql_for_log = args ? "#{sql}; #{args.inspect}" : sql
      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

  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sequel-rails-0.7.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.6.1 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.6.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.5.1 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.5.0 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.4.4 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.4.3 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.4.2 lib/sequel_rails/sequel/database/active_support_notification.rb
sequel-rails-0.4.1 lib/sequel_rails/sequel/database/active_support_notification.rb