Sha256: 23066388c68b0005b7d38b1428463c13d18e00dbdf8ca56f9070fa21ad335f27
Contents?: true
Size: 1.29 KB
Versions: 12
Compression:
Stored size: 1.29 KB
Contents
module Logster module Middleware class Reporter PATH_INFO = "PATH_INFO".freeze def initialize(app, config={}) @app = app @error_path = (Logster.config.subdirectory || '/logs') + '/report_js_error' end def call(env) Thread.current[Logster::Logger::LOGSTER_ENV] = env path = env[PATH_INFO] 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 def report_js_error(env) req = Rack::Request.new(env) message = req["message"] || "" message << "\nUrl: " << req["url"] if req["url"] message << "\nLine: " << req["line"] if req["line"] message << "\nColumn: " << req["column"] if req["column"] message << "\nWindow Location: " << req["window_location"] if req["window_location"] backtrace = req["stacktrace"] || "" Logster.store.report(::Logger::Severity::WARN, "javascript", message, backtrace: backtrace, env: env) end end end end
Version data entries
12 entries across 12 versions & 1 rubygems