module Sequel::CallerLogging

Constants

INTERNAL
RUBY_STDLIB
SEQUEL_LIB_PATH

Attributes

caller_logging_formatter[RW]

A callable to format the external caller

caller_logging_ignore[RW]

A regexp of caller lines to ignore, in addition to internal Sequel and Ruby code.

Public Instance Methods

log_connection_yield(sql, conn, args=nil) click to toggle source

Include caller information when logging query.

Calls superclass method
# File lib/sequel/extensions/caller_logging.rb, line 48
def log_connection_yield(sql, conn, args=nil)
  if !@loggers.empty? && (external_caller = external_caller_for_log)
    sql = "#{external_caller} #{sql}"
  end
  super
end

Private Instance Methods

external_caller_for_log() click to toggle source

The caller to log, ignoring internal Sequel and Ruby code, and user specified lines to ignore.

# File lib/sequel/extensions/caller_logging.rb, line 59
def external_caller_for_log
  ignore = caller_logging_ignore
  c = caller.find do |line|
    !(line.start_with?(SEQUEL_LIB_PATH) ||
      line.start_with?(RUBY_STDLIB) ||
      line.start_with?(INTERNAL) ||
      (ignore && line =~ ignore))
  end

  if c
    c = if formatter = caller_logging_formatter
      formatter.call(c)
    else
      "(source: #{c})"
    end
  end

  c
end