Sha256: 4513fb153afb22a5111cc3584433d83e63b140056587713a8fead7cfb8aba149

Contents?: true

Size: 651 Bytes

Versions: 2

Compression:

Stored size: 651 Bytes

Contents

module DataMapper
  module Railties

    class LogSubscriber < Rails::LogSubscriber

      def initialize
        super
        @odd_or_even = false
      end

      def sql(event)
        name = '%s (%.1fms)' % [event.payload[:name], event.duration]
        sql  = event.payload[:sql].squeeze(' ')

        if odd?
          name = color(name, :cyan, true)
          sql  = color(sql, nil, true)
        else
          name = color(name, :magenta, true)
        end

        debug "  #{name}  #{sql}"
      end

      def odd?
        @odd_or_even = !@odd_or_even
      end

      def logger
        ::DataMapper.logger
      end

    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dm-rails-1.0.0 lib/dm-rails/railties/log_subscriber.rb
dm-rails-1.0.0.rc3 lib/dm-rails/railties/log_subscriber.rb