Class: Logput::Middleware

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

Overview

Middleware

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ Middleware

Returns a new instance of Middleware.



5
6
7
8
9
# File 'lib/logput/middleware.rb', line 5

def initialize(app, options = {})
  @app = app
  @path_to_log_file = options[:path_to_log_file]
  @lines_to_read = options[:lines_to_read] || 500
end

Instance Method Details

#call(env) ⇒ Object

Call



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/logput/middleware.rb', line 12

def call(env)
  @env = env
  @path_to_log_file ||= default_path_to_log_file

  ensure_log_file_exists!

  if is_logput?
    generate_output!
  else
    @app.call(@env)
  end
end