26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/omniauth-slack/debug.rb', line 26
def debug(method_name = nil, klass=nil, &block)
method_name ||= caller_method_name
klass ||= self
filter = ENV['OMNIAUTH_SLACK_DEBUG']
return if filter.nil? || filter.to_s=='' || LOG_NONE.include?(filter.to_s.downcase)
klass = case klass
when Class; klass.name
when Module; klass.name
when String; klass
else klass.to_s
end
klass_name = klass.to_s.split('::').last.to_s
log_text = yield
full_text = "(#{klass_name} #{method_name}) #{log_text}"
if filter && !LOG_ALL.include?(filter.to_s.downcase)
regexp = filter.is_a?(Regexp) ? filter : Regexp.new(filter.to_s, true)
return unless full_text[regexp]
end
OmniAuth.logger.log(Logger::TRACE, full_text)
end
|