exception-track 0.6.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/config/exception_track_manifest.js +0 -0
- data/app/controllers/exception_track/logs_controller.rb +1 -2
- data/config/initializers/exception-track.rb +11 -6
- data/db/migrate/20170217023900_create_exception_track_logs.rb +1 -1
- data/lib/exception-track.rb +2 -0
- data/lib/exception-track/configuration.rb +1 -0
- data/lib/exception-track/engine.rb +3 -1
- data/lib/exception-track/log_subscriber.rb +12 -0
- data/lib/exception-track/version.rb +1 -1
- data/lib/exception_notifier/exception_track_notifier.rb +22 -20
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b4beb51819395e0c6b21ef49abb59bc7095781ce085e0926e7c63f5b6d2e117
|
4
|
+
data.tar.gz: 50f9c9af65bbab093ca3ed4e50b1a3d4ae6ad5768672ec11d4fce68a3a5c2cc1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46741761f713ee98cb71ea661d10048131e67b0e309f402cbfa1921e7780a52225c58e9f3ec082500360514aecc32982a2c33066d2949f9e2466be02bedc58f3
|
7
|
+
data.tar.gz: f2c71737f37cf474633477bbf00ce601875d68c4b6040be260e857f264818d247707c1f2b4ab38f29fe58e963a4a5604bcce0ee66a7f940ecc0209b3eec4d6b9
|
File without changes
|
@@ -12,7 +12,7 @@ module ExceptionTrack
|
|
12
12
|
|
13
13
|
def export
|
14
14
|
@logs = Log.order("id desc").where("created_at >= ?", 3.months.ago)
|
15
|
-
send_data JSON.pretty_generate(@logs.as_json(only: [
|
15
|
+
send_data JSON.pretty_generate(@logs.as_json(only: %i[title body created_at updated_at])), filename: "#{Date.current}.json", disposition: "attachment"
|
16
16
|
end
|
17
17
|
|
18
18
|
# GET /exception_logs/1
|
@@ -25,7 +25,6 @@ module ExceptionTrack
|
|
25
25
|
end
|
26
26
|
|
27
27
|
private
|
28
|
-
|
29
28
|
# Use callbacks to share common setup or constraints between actions.
|
30
29
|
def set_log
|
31
30
|
@log = Log.find(params[:id])
|
@@ -9,10 +9,15 @@ ExceptionTrack.configure do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
# ExceptionNotification.configure do |config|
|
12
|
-
# config.ignored_exceptions += %w
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
12
|
+
# config.ignored_exceptions += %w[
|
13
|
+
# ActionView::TemplateError
|
14
|
+
# ActionController::InvalidAuthenticityToken
|
15
|
+
# ActionController::BadRequest
|
16
|
+
# ActionView::MissingTemplate
|
17
|
+
# ActionController::UrlGenerationError
|
18
|
+
# ActionController::UnknownFormat
|
19
|
+
# ActionController::InvalidCrossOriginRequest
|
20
|
+
# ActionController::ParameterMissing
|
21
|
+
# Mime::Type::InvalidMimeType
|
22
|
+
# ]
|
18
23
|
# end
|
data/lib/exception-track.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "exception-track/version"
|
4
4
|
require "exception-track/configuration"
|
5
|
+
require "exception-track/log_subscriber"
|
5
6
|
require "exception-track/engine"
|
6
7
|
|
7
8
|
require "exception_notification"
|
@@ -14,6 +15,7 @@ module ExceptionTrack
|
|
14
15
|
class << self
|
15
16
|
def config
|
16
17
|
return @config if defined?(@config)
|
18
|
+
|
17
19
|
@config = Configuration.new
|
18
20
|
@config.environments = %i[development production]
|
19
21
|
@config
|
@@ -5,7 +5,9 @@ module ExceptionTrack
|
|
5
5
|
isolate_namespace ExceptionTrack
|
6
6
|
|
7
7
|
initializer "exception-track.assets.precompile", group: :all do |app|
|
8
|
-
app.config.assets.precompile += %w
|
8
|
+
app.config.assets.precompile += %w[exception-track/application.css]
|
9
9
|
end
|
10
|
+
|
11
|
+
ExceptionTrack::LogSubscriber.attach_to :exception_track
|
10
12
|
end
|
11
13
|
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ExceptionTrack
|
4
|
+
class LogSubscriber < ActiveSupport::LogSubscriber
|
5
|
+
# ActiveSupport::Notifications.instrument('track.exception_track', action: action)
|
6
|
+
def track(event)
|
7
|
+
prefix = color("ExceptionTrack", CYAN)
|
8
|
+
title = color(event.payload[:title], RED)
|
9
|
+
debug " #{prefix} track db (#{event.duration.round(1)}ms)"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -2,27 +2,31 @@
|
|
2
2
|
|
3
3
|
module ExceptionNotifier
|
4
4
|
class ExceptionTrackNotifier < ExceptionNotifier::BaseNotifier
|
5
|
-
def initialize(
|
5
|
+
def initialize(_opts); end
|
6
6
|
|
7
|
-
def call(exception,
|
7
|
+
def call(exception, opts = {})
|
8
8
|
return unless ExceptionTrack.config.enabled_env?(Rails.env)
|
9
9
|
|
10
10
|
# send the notification
|
11
11
|
title = exception.message || "None"
|
12
|
-
|
13
12
|
messages = []
|
14
|
-
messages << headers_for_env(_options[:env])
|
15
|
-
messages << ""
|
16
|
-
messages << "--------------------------------------------------"
|
17
|
-
messages << ""
|
18
|
-
messages << exception.inspect
|
19
|
-
unless exception.backtrace.blank?
|
20
|
-
messages << "\n"
|
21
|
-
messages << exception.backtrace
|
22
|
-
end
|
23
13
|
|
24
|
-
|
25
|
-
|
14
|
+
ActiveSupport::Notifications.instrument("track.exception_track", title: title) do
|
15
|
+
messages << headers_for_env(opts[:env])
|
16
|
+
messages << ""
|
17
|
+
messages << "--------------------------------------------------"
|
18
|
+
messages << ""
|
19
|
+
messages << exception.inspect
|
20
|
+
unless exception.backtrace.blank?
|
21
|
+
messages << "\n"
|
22
|
+
messages << exception.backtrace
|
23
|
+
end
|
24
|
+
|
25
|
+
Rails.logger.silence do
|
26
|
+
ExceptionTrack::Log.create(title: title[0, 200], body: messages.join("\n"))
|
27
|
+
end
|
28
|
+
end
|
29
|
+
rescue StandardError => e
|
26
30
|
errs = []
|
27
31
|
errs << "-- [ExceptionTrack] create error ---------------------------"
|
28
32
|
errs << e.message.indent(2)
|
@@ -43,9 +47,7 @@ module ExceptionNotifier
|
|
43
47
|
headers = []
|
44
48
|
headers << "Method: #{env['REQUEST_METHOD']}"
|
45
49
|
headers << "URL: #{env['REQUEST_URI']}"
|
46
|
-
if env[
|
47
|
-
headers << "Parameters:\n#{pretty_hash(parameters.except(:controller, :action), 13)}"
|
48
|
-
end
|
50
|
+
headers << "Parameters:\n#{pretty_hash(parameters.except(:controller, :action), 13)}" if env["REQUEST_METHOD"].downcase != "get"
|
49
51
|
headers << "Controller: #{parameters['controller']}##{parameters['action']}"
|
50
52
|
headers << "RequestId: #{env['action_dispatch.request_id']}"
|
51
53
|
headers << "User-Agent: #{env['HTTP_USER_AGENT']}"
|
@@ -60,10 +62,10 @@ module ExceptionNotifier
|
|
60
62
|
def filter_parameters(env)
|
61
63
|
parameters = env["action_dispatch.request.parameters"] || {}
|
62
64
|
parameter_filter = ActiveSupport::ParameterFilter.new(env["action_dispatch.parameter_filter"] || [])
|
63
|
-
|
64
|
-
rescue => e
|
65
|
+
parameter_filter.filter(parameters)
|
66
|
+
rescue StandardError => e
|
65
67
|
Rails.logger.error "filter_parameters error: #{e.inspect}"
|
66
|
-
|
68
|
+
parameters
|
67
69
|
end
|
68
70
|
|
69
71
|
def pretty_hash(params, indent = 0)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception-track
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exception_notification
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- MIT-LICENSE
|
78
78
|
- README.md
|
79
|
+
- app/assets/config/exception_track_manifest.js
|
79
80
|
- app/assets/stylesheets/exception-track/application.css
|
80
81
|
- app/controllers/exception_track/logs_controller.rb
|
81
82
|
- app/models/exception_track/log.rb
|
@@ -88,6 +89,7 @@ files:
|
|
88
89
|
- lib/exception-track.rb
|
89
90
|
- lib/exception-track/configuration.rb
|
90
91
|
- lib/exception-track/engine.rb
|
92
|
+
- lib/exception-track/log_subscriber.rb
|
91
93
|
- lib/exception-track/version.rb
|
92
94
|
- lib/exception_notifier/exception_track_notifier.rb
|
93
95
|
- lib/generators/exception_track/install_generator.rb
|