Class: LogsExplorer::Rails::Middleware

Inherits:
Object
  • Object
show all
Defined in:
lib/logs_explorer/rails/middleware.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ Middleware

Returns a new instance of Middleware.



6
7
8
# File 'lib/logs_explorer/rails/middleware.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
# File 'lib/logs_explorer/rails/middleware.rb', line 10

def call(env)
  dup.call!(env)
end

#call!(env) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/logs_explorer/rails/middleware.rb', line 14

def call!(env)
  if env['PATH_INFO'] =~ /logs-explorer/
    # in_silence { @status, @headers, @response = @app.call(env) }

    ::Rails.logger.silence do
      @status, @headers, @response = @app.call(env)
    end
  else
    @status, @headers, @response = @app.call(env)
  end

  [@status, @headers, @response]
end

#in_silenceObject



27
28
29
30
31
32
33
34
35
# File 'lib/logs_explorer/rails/middleware.rb', line 27

def in_silence
  old_level = ::Rails.logger.level.dup
  begin
    ::Rails.logger.level = Logger::ERROR
    yield
  ensure
    ::Rails.logger.level = old_level
  end
end