exception-track 0.5.2 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/config/exception_track_manifest.js +0 -2
- data/app/assets/stylesheets/exception-track/application.css +22 -10
- data/app/controllers/exception_track/logs_controller.rb +5 -1
- data/app/views/exception_track/logs/index.html.erb +3 -0
- data/config/initializers/exception-track.rb +11 -6
- data/config/routes.rb +1 -0
- data/db/migrate/20170217023900_create_exception_track_logs.rb +2 -2
- data/lib/exception-track.rb +2 -0
- data/lib/exception-track/configuration.rb +1 -0
- data/lib/exception-track/engine.rb +6 -0
- 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 +34 -15
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 204adb921c2d193136a838e4b3612e80162b59eda35b0e6c245c529038d98d88
|
4
|
+
data.tar.gz: eb21c43240e595356f99c4790112120f337625d4ba9da0359fe30dbb6f9fc774
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 350a1ba8b5ec9836b93c38cb40f68083fbb484a7c7435a39025068cafb50eeb6def491f187c3c29cba24f0fd5ead757c3f435fcad896c2ce49e2c05420657675
|
7
|
+
data.tar.gz: c602e2dd3ba3bd8f5bef4bee20c4910c72733e8557d14831751a46b55ecbcaf918de7a96c7d492c7dcc144147a474758105cd715c95ce2c4ce4900ab963e746d
|
@@ -6,7 +6,7 @@ body {
|
|
6
6
|
}
|
7
7
|
|
8
8
|
body, textarea {
|
9
|
-
font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
|
9
|
+
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, Helvetica, sans-serif;
|
10
10
|
font-size: 14px;
|
11
11
|
line-height: 1.4;
|
12
12
|
color: #333;
|
@@ -38,7 +38,7 @@ table {
|
|
38
38
|
|
39
39
|
th {
|
40
40
|
text-align: left;
|
41
|
-
border-bottom: solid 1px #
|
41
|
+
border-bottom: solid 1px #e0e0e0;
|
42
42
|
}
|
43
43
|
|
44
44
|
td.date { width: 150px; font-size: 12px; }
|
@@ -66,9 +66,9 @@ ul {
|
|
66
66
|
table td, table th {
|
67
67
|
padding: 10px 15px;
|
68
68
|
}
|
69
|
-
th { background: #f5f5f5; border-bottom: 1px solid #
|
69
|
+
th { background: #f5f5f5; border-bottom: 1px solid #e0e0e0; }
|
70
70
|
td {
|
71
|
-
border-top: solid 1px #
|
71
|
+
border-top: solid 1px #e0e0e0;
|
72
72
|
}
|
73
73
|
|
74
74
|
pre {
|
@@ -108,12 +108,16 @@ hr {
|
|
108
108
|
user-select: none;
|
109
109
|
border-radius: 3px;
|
110
110
|
border: 1px solid #ccc;
|
111
|
-
padding:
|
111
|
+
padding: 6px 16px;
|
112
|
+
color: #555 !important;
|
112
113
|
outline: 0 !important;
|
113
114
|
background: #FFF;
|
114
115
|
}
|
115
|
-
.btn:hover { text-decoration: none; }
|
116
|
-
.btn-danger { background: #
|
116
|
+
.btn:hover { text-decoration: none !important; background: #f7f7f7; }
|
117
|
+
.btn-danger { background: #fff; color: #E33F00 !important; border-color: #E33F00;}
|
118
|
+
.btn-danger:hover {
|
119
|
+
background: #FCEDEC;
|
120
|
+
}
|
117
121
|
|
118
122
|
.container {
|
119
123
|
max-width: 1000px;
|
@@ -121,6 +125,8 @@ hr {
|
|
121
125
|
margin-right: auto;
|
122
126
|
padding: 20px;
|
123
127
|
background-color: #fff;
|
128
|
+
box-shadow: 0 1px 8px rgba(200, 200, 200, 0.26);
|
129
|
+
border-radius: 3px;
|
124
130
|
}
|
125
131
|
|
126
132
|
.no-record {
|
@@ -134,6 +140,7 @@ hr {
|
|
134
140
|
height: 34px;
|
135
141
|
line-height: 34px;
|
136
142
|
}
|
143
|
+
.toolbar form { display: inline; }
|
137
144
|
.toolbar .pull-right { float: right; }
|
138
145
|
|
139
146
|
#notice {
|
@@ -145,9 +152,9 @@ hr {
|
|
145
152
|
}
|
146
153
|
|
147
154
|
pre {
|
148
|
-
background: #
|
149
|
-
padding:
|
150
|
-
border:
|
155
|
+
background: #f7f7f7;
|
156
|
+
padding: 25px;
|
157
|
+
border-radius: 3px;
|
151
158
|
font-size: 12px;
|
152
159
|
font-family: Menlo, Monaco, Consolas, monospace;
|
153
160
|
}
|
@@ -165,6 +172,11 @@ h1 { font-size: 16px; }
|
|
165
172
|
display: inline-block;
|
166
173
|
padding: 5px 10px;
|
167
174
|
border: 1px solid #eee;
|
175
|
+
color: #555;
|
176
|
+
text-decoration: none;
|
177
|
+
}
|
178
|
+
.pagination a:hover {
|
179
|
+
background: #f7f7f7;
|
168
180
|
}
|
169
181
|
.pagination em,
|
170
182
|
.pagination .current {
|
@@ -10,6 +10,11 @@ module ExceptionTrack
|
|
10
10
|
@logs = Log.order("id desc").page(params[:page]).per(15)
|
11
11
|
end
|
12
12
|
|
13
|
+
def export
|
14
|
+
@logs = Log.order("id desc").where("created_at >= ?", 3.months.ago)
|
15
|
+
send_data JSON.pretty_generate(@logs.as_json(only: %i[title body created_at updated_at])), filename: "#{Date.current}.json", disposition: "attachment"
|
16
|
+
end
|
17
|
+
|
13
18
|
# GET /exception_logs/1
|
14
19
|
def show; end
|
15
20
|
|
@@ -20,7 +25,6 @@ module ExceptionTrack
|
|
20
25
|
end
|
21
26
|
|
22
27
|
private
|
23
|
-
|
24
28
|
# Use callbacks to share common setup or constraints between actions.
|
25
29
|
def set_log
|
26
30
|
@log = Log.find(params[:id])
|
@@ -9,6 +9,9 @@
|
|
9
9
|
<%= @logs.total_count %> exceptions
|
10
10
|
|
11
11
|
<div class="pull-right">
|
12
|
+
<%= form_tag(export_logs_path, method: 'post') do %>
|
13
|
+
<button type="submit" class="btn">Export last 3 months</button>
|
14
|
+
<% end %>
|
12
15
|
<%= form_tag(all_logs_path, method: 'delete') do %>
|
13
16
|
<button type="submit" class="btn btn-danger" onclick="return confirmDestroyAll()">Delete All</button>
|
14
17
|
<% end %>
|
@@ -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/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
class CreateExceptionTrackLogs < ActiveRecord::Migration[5.
|
3
|
+
class CreateExceptionTrackLogs < ActiveRecord::Migration[5.2]
|
4
4
|
def change
|
5
5
|
create_table :exception_tracks do |t|
|
6
6
|
t.string :title
|
7
|
-
t.text :body, limit:
|
7
|
+
t.text :body, limit: 16_777_215
|
8
8
|
|
9
9
|
t.timestamps
|
10
10
|
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
|
@@ -3,5 +3,11 @@
|
|
3
3
|
module ExceptionTrack
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
isolate_namespace ExceptionTrack
|
6
|
+
|
7
|
+
initializer "exception-track.assets.precompile", group: :all do |app|
|
8
|
+
app.config.assets.precompile += %w[exception-track/application.css]
|
9
|
+
end
|
10
|
+
|
11
|
+
ExceptionTrack::LogSubscriber.attach_to :exception_track
|
6
12
|
end
|
7
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)
|
@@ -38,11 +42,12 @@ module ExceptionNotifier
|
|
38
42
|
def headers_for_env(env)
|
39
43
|
return "" if env.blank?
|
40
44
|
|
41
|
-
parameters = env
|
45
|
+
parameters = filter_parameters(env)
|
42
46
|
|
43
47
|
headers = []
|
44
48
|
headers << "Method: #{env['REQUEST_METHOD']}"
|
45
49
|
headers << "URL: #{env['REQUEST_URI']}"
|
50
|
+
headers << "Parameters:\n#{pretty_hash(parameters.except(:controller, :action), 13)}" if env["REQUEST_METHOD"].downcase != "get"
|
46
51
|
headers << "Controller: #{parameters['controller']}##{parameters['action']}"
|
47
52
|
headers << "RequestId: #{env['action_dispatch.request_id']}"
|
48
53
|
headers << "User-Agent: #{env['HTTP_USER_AGENT']}"
|
@@ -53,5 +58,19 @@ module ExceptionNotifier
|
|
53
58
|
|
54
59
|
headers.join("\n")
|
55
60
|
end
|
61
|
+
|
62
|
+
def filter_parameters(env)
|
63
|
+
parameters = env["action_dispatch.request.parameters"] || {}
|
64
|
+
parameter_filter = ActiveSupport::ParameterFilter.new(env["action_dispatch.parameter_filter"] || [])
|
65
|
+
parameter_filter.filter(parameters)
|
66
|
+
rescue StandardError => e
|
67
|
+
Rails.logger.error "filter_parameters error: #{e.inspect}"
|
68
|
+
parameters
|
69
|
+
end
|
70
|
+
|
71
|
+
def pretty_hash(params, indent = 0)
|
72
|
+
json = JSON.pretty_generate(params)
|
73
|
+
json.indent(indent)
|
74
|
+
end
|
56
75
|
end
|
57
76
|
end
|
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:
|
4
|
+
version: 1.1.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:
|
11
|
+
date: 2020-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: exception_notification
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '5.2'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '5.2'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: mysql2
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -89,6 +89,7 @@ files:
|
|
89
89
|
- lib/exception-track.rb
|
90
90
|
- lib/exception-track/configuration.rb
|
91
91
|
- lib/exception-track/engine.rb
|
92
|
+
- lib/exception-track/log_subscriber.rb
|
92
93
|
- lib/exception-track/version.rb
|
93
94
|
- lib/exception_notifier/exception_track_notifier.rb
|
94
95
|
- lib/generators/exception_track/install_generator.rb
|
@@ -111,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
112
|
- !ruby/object:Gem::Version
|
112
113
|
version: '0'
|
113
114
|
requirements: []
|
114
|
-
rubygems_version: 3.0.
|
115
|
+
rubygems_version: 3.0.3
|
115
116
|
signing_key:
|
116
117
|
specification_version: 4
|
117
118
|
summary: Tracking exceptions for Rails application store them in database.
|