Skip to content

Commit

Permalink
Add Bizside::Rails::Rack::Logger
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shimojo committed Aug 13, 2024
1 parent de07c12 commit 5373d59
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions lib/bizside/rails/rack/logger.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module Bizside
module Rails
module Rack
class Logger < ::Rails::Rack::Logger
def initialize(app, taggers = nil, config = {})
super(app, taggers)
@config = config
@config[:ignore_paths] ||= []
end

def ignore?(env)
@config[:ignore_paths].any? do |path|
case path
when Regexp
env['REQUEST_URI'] =~ path
else
env['REQUEST_URI'] == path
end
end
end

def call(env)
if ignore?(env)
Rails.logger.silence { super }
else
super
end
end
end
end
end
end

0 comments on commit 5373d59

Please sign in to comment.