Method: WhyQuery.log_origin

Defined in:
lib/why_query.rb

.log_originObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/why_query.rb', line 26

def log_origin
  stack = caller_locations(3, 10)

  location = stack.find do |loc|
    path = loc.path
    path.start_with?(Rails.root.to_s) && !path.include?("/gems/")
  end if config.app_only

  location ||= stack[0] # fallback to any top stack

  if location
    config.logger.call("↳ Called from: #{location.path.sub(Rails.root.to_s + "/", "")}:#{location.lineno}")
  end
end