Class: Sequel::Railties::LogSubscriber

Inherits:
ActiveSupport::LogSubscriber
  • Object
show all
Defined in:
lib/sequel-rails/railties/log_subscriber.rb

Instance Method Summary collapse

Instance Method Details

#loggerObject



24
25
26
# File 'lib/sequel-rails/railties/log_subscriber.rb', line 24

def logger
  ::Rails::Sequel.configuration.logger
end

#odd?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/sequel-rails/railties/log_subscriber.rb', line 20

def odd?
  @odd_or_even = !@odd_or_even
end

#sql(event) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/sequel-rails/railties/log_subscriber.rb', line 6

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