Class: Rack::Lineprof
- Inherits:
-
Object
- Object
- Rack::Lineprof
- Defined in:
- lib/rack/lineprof.rb,
lib/rack/lineprof/sample.rb,
lib/rack/lineprof/source.rb
Defined Under Namespace
Constant Summary collapse
- CONTEXT =
0
- NOMINAL =
1
- WARNING =
2
- CRITICAL =
3
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #call(env) ⇒ Object
- #format_profile(profile) ⇒ Object
-
#initialize(app, options = {}) ⇒ Lineprof
constructor
A new instance of Lineprof.
Constructor Details
#initialize(app, options = {}) ⇒ Lineprof
Returns a new instance of Lineprof.
18 19 20 |
# File 'lib/rack/lineprof.rb', line 18 def initialize app, = {} @app, @options = app, end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
16 17 18 |
# File 'lib/rack/lineprof.rb', line 16 def app @app end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
16 17 18 |
# File 'lib/rack/lineprof.rb', line 16 def @options end |
Instance Method Details
#call(env) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/rack/lineprof.rb', line 22 def call env request = Rack::Request.new env matcher = request.params['lineprof'] || [:profile] logger = [:logger] || ::Logger.new(STDOUT) return @app.call env unless matcher response = nil profile = lineprof(%r{#{matcher}}) { response = @app.call env } logger.debug Term::ANSIColor.blue("\n[Rack::Lineprof] #{'=' * 63}") + "\n\n" + format_profile(profile) + "\n" response end |