class Apartment::LogSubscriber
Custom Log subscriber to include database name and schema name in sql logs
Public Instance Methods
sql(event)
click to toggle source
NOTE: for some reason, if the method definition is not here, then the custom debug method is not called rubocop:disable Lint/UselessMethodDefinition
Calls superclass method
# File lib/apartment/log_subscriber.rb, line 10 def sql(event) super(event) end
Private Instance Methods
apartment_log()
click to toggle source
# File lib/apartment/log_subscriber.rb, line 23 def apartment_log database = color("[#{Apartment.connection.raw_connection.db}] ", ActiveSupport::LogSubscriber::MAGENTA, true) schema = nil unless Apartment.connection.schema_search_path.nil? schema = color("[#{Apartment.connection.schema_search_path.tr('"', '')}] ", ActiveSupport::LogSubscriber::YELLOW, true) end "#{database}#{schema}" end
debug(progname = nil, &block)
click to toggle source
rubocop:enable Lint/UselessMethodDefinition
Calls superclass method
# File lib/apartment/log_subscriber.rb, line 17 def debug(progname = nil, &block) progname = " #{apartment_log}#{progname}" unless progname.nil? super(progname, &block) end