Sha256: 409d637454ea21d28baa3dc3670c2b083391fbb16a3c775c76476e0fcb8c6b09

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

module Rails
  module Sequel
    module Railties
      class LogSubscriber < Rails::LogSubscriber
        def sql(event)
          name = '%s (%.1fms)' % [event.payload[:name], event.payload[: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

        # by default, Rails.logger will be used
        # if users want additional loggers, they can specify through the yml file

        private

        def odd?
          @odd_or_even = !@odd_or_even
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails3_sequel-0.3.0 lib/rails3_sequel/railties/log_subscriber.rb
rails3_sequel-0.2.2 lib/rails3_sequel/railties/log_subscriber.rb
rails3_sequel-0.2.1 lib/rails3_sequel/railties/log_subscriber.rb