Skip to content

Commit

Permalink
improve request strategy logging
Browse files Browse the repository at this point in the history
  • Loading branch information
Borzik committed Jul 23, 2017
1 parent a3ea198 commit 0376f1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/chewy/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def self.all_engines
class RequestStrategy
def initialize(app)
@app = app
Chewy.logger.debug("Chewy strategies stack: [1] <- #{Chewy.request_strategy}")
end

def call(env)
Expand Down
6 changes: 3 additions & 3 deletions lib/chewy/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ def current

def push(name)
result = @stack.push resolve(name).new
debug "[#{@stack.size}] <- #{current.name}"
debug "[#{@stack.size-1}] <- #{current.name}" if @stack.length > 2
result
end

def pop
raise "Can't pop root strategy" if @stack.one?
debug "[#{@stack.size}] -> #{current.name}"
result = @stack.pop.tap(&:leave)
debug "[#{@stack.size}] -> #{result.name}, now #{current.name}" if @stack.size > 1
result
end

Expand All @@ -77,7 +77,7 @@ def wrap(name)
def debug(string)
return unless Chewy.logger && Chewy.logger.debug?
line = caller.detect { |l| l !~ %r{lib/chewy/strategy.rb:|lib/chewy.rb:} }
Chewy.logger.debug(["DEBUG: Chewy strategies stack: #{string}", line.sub(/:in\s.+$/, '')].join(' @ '))
Chewy.logger.debug([ "Chewy strategies stack: #{string}", line.sub(/:in\s.+$/, '') ].join(' @ '))
end

def resolve(name)
Expand Down

0 comments on commit 0376f1d

Please sign in to comment.