Sha256: 64c6eec6a4378ad99ccaa6b287e7a599fee9778d8c84d7fe2c52e2be4adbd061
Contents?: true
Size: 829 Bytes
Versions: 11
Compression:
Stored size: 829 Bytes
Contents
# frozen_string_literal: true require 'active_support/log_subscriber' module ROM module SQL class RailsLogSubscriber < ActiveSupport::LogSubscriber def sql(event) return unless logger.debug? payload = event.payload name = format('%s (%.1fms)', payload[:name], event.duration) sql = payload[:sql].squeeze(' ') binds = payload[:binds].to_a.inspect if payload[:binds] if odd? name = color(name, :cyan, true) sql = color(sql, nil, true) else name = color(name, :magenta, true) end debug " #{name} #{sql} #{binds}" end attr_reader :odd_or_even private :odd_or_even def odd? @odd_or_even = !odd_or_even end end end end ROM::SQL::RailsLogSubscriber.attach_to(:rom)
Version data entries
11 entries across 11 versions & 1 rubygems