Class: Logster::Middleware::Reporter
- Inherits:
-
Object
- Object
- Logster::Middleware::Reporter
- Defined in:
- lib/logster/middleware/reporter.rb
Constant Summary collapse
- PATH_INFO =
"PATH_INFO".freeze
- SCRIPT_NAME =
"SCRIPT_NAME".freeze
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, config = {}) ⇒ Reporter
constructor
A new instance of Reporter.
- #report_js_error(env) ⇒ Object
Constructor Details
Instance Method Details
#call(env) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/logster/middleware/reporter.rb', line 13 def call(env) Thread.current[Logster::Logger::LOGSTER_ENV] = env path = env[PATH_INFO] script_name = env[SCRIPT_NAME] if script_name && script_name.length > 0 path = script_name + path end if path == @error_path Logster.config.current_context.call(env) do report_js_error(env) end return [200,{},["OK"]] end @app.call(env) ensure Thread.current[Logster::Logger::LOGSTER_ENV] = nil end |
#report_js_error(env) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/logster/middleware/reporter.rb', line 36 def report_js_error(env) req = Rack::Request.new(env) = req["message"] || "" << "\nUrl: " << req["url"] if req["url"] << "\nLine: " << req["line"] if req["line"] << "\nColumn: " << req["column"] if req["column"] << "\nWindow Location: " << req["window_location"] if req["window_location"] backtrace = req["stacktrace"] || "" Logster.store.report(::Logger::Severity::WARN, "javascript", , backtrace: backtrace, env: env) end |