Class: TinyIRC::AppLogger
- Inherits:
-
Object
- Object
- TinyIRC::AppLogger
- Defined in:
- lib/tinyirc/app.rb
Class Attribute Summary collapse
-
.log ⇒ Object
Returns the value of attribute log.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ AppLogger
constructor
A new instance of AppLogger.
Constructor Details
#initialize(app) ⇒ AppLogger
Returns a new instance of AppLogger.
9 10 11 |
# File 'lib/tinyirc/app.rb', line 9 def initialize(app) @app = app end |
Class Attribute Details
.log ⇒ Object
Returns the value of attribute log.
3 4 5 |
# File 'lib/tinyirc/app.rb', line 3 def log @log end |
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/tinyirc/app.rb', line 13 def call(env) @start = Time.now @status, @headers, @body = @app.call(env) @duration = ((Time.now - @start).to_f * 1000).round(2) TinyIRC::AppLogger.log.io "#{env['REMOTE_ADDR']} --- #{env['REQUEST_METHOD']} #{env['REQUEST_PATH']} --- #{@duration} ms" [@status, @headers, @body] end |