faultline-rails 0.4.0 → 0.7.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/README.md +14 -0
- data/app/assets/stylesheets/faultline/application.css +0 -41
- data/app/assets/stylesheets/faultline/dashboard.css +961 -0
- data/app/controllers/faultline/logged_exceptions_controller.rb +81 -8
- data/app/helpers/faultline/logged_exceptions_helper.rb +84 -5
- data/app/javascript/controllers/faultline_controller.js +349 -7
- data/app/javascript/faultline/controllers/sidebar_controller.js +21 -0
- data/app/javascript/faultline/controllers/theme_controller.js +48 -0
- data/app/models/faultline/logged_exception.rb +10 -0
- data/app/views/faultline/logged_exceptions/_exceptions.html.erb +132 -84
- data/app/views/faultline/logged_exceptions/_show.html.erb +281 -60
- data/app/views/faultline/logged_exceptions/index.html.erb +192 -123
- data/app/views/faultline/logged_exceptions/show.html.erb +1 -1
- data/app/views/layouts/faultline/application.html.erb +116 -51
- data/faultline-rails.gemspec +1 -0
- data/lib/faultline/cleanup.rb +32 -0
- data/lib/faultline/configuration.rb +172 -4
- data/lib/faultline/engine.rb +22 -0
- data/lib/faultline/logger.rb +188 -0
- data/lib/faultline/notifications.rb +80 -0
- data/lib/faultline/ransack_config.rb +2 -24
- data/lib/faultline/version.rb +1 -1
- data/lib/faultline.rb +10 -0
- data/lib/generators/faultline/customize_generator.rb +117 -0
- data/lib/generators/faultline/install_generator.rb +15 -0
- data/lib/generators/faultline/templates/faultline.rb +70 -37
- data/lib/generators/faultline/templates/javascript/controllers/faultline_controller.js +310 -0
- data/lib/generators/faultline/templates/views/faultline/logged_exceptions/_exceptions.html.erb +124 -0
- data/lib/generators/faultline/templates/views/faultline/logged_exceptions/_show.html.erb +83 -0
- data/lib/generators/faultline/templates/views/faultline/logged_exceptions/index.html.erb +113 -0
- data/lib/generators/faultline/templates/views/layouts/faultline/application.html.erb +133 -0
- data/lib/tasks/faultline.rake +147 -0
- metadata +15 -1
|
@@ -13,6 +13,9 @@ module Faultline
|
|
|
13
13
|
|
|
14
14
|
desc "Install Faultline: creates migration, initializer, and mounts routes."
|
|
15
15
|
|
|
16
|
+
class_option :modern, type: :boolean, default: false,
|
|
17
|
+
desc: "Generate customizable views, layout, and Stimulus controller"
|
|
18
|
+
|
|
16
19
|
def self.next_migration_number(path)
|
|
17
20
|
# Generate timestamp-based migration number for Rails 8.1+ compatibility
|
|
18
21
|
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
|
@@ -41,6 +44,12 @@ module Faultline
|
|
|
41
44
|
say "Add the following to your ApplicationController:\n\n include Faultline::ExceptionLoggable\n"
|
|
42
45
|
end
|
|
43
46
|
|
|
47
|
+
def generate_modern_views
|
|
48
|
+
return unless options[:modern]
|
|
49
|
+
|
|
50
|
+
generate "faultline:customize"
|
|
51
|
+
end
|
|
52
|
+
|
|
44
53
|
def display_post_install
|
|
45
54
|
say ""
|
|
46
55
|
say "Faultline has been installed!", :green
|
|
@@ -51,6 +60,12 @@ module Faultline
|
|
|
51
60
|
say ""
|
|
52
61
|
say "Protect the dashboard by editing config/initializers/faultline.rb"
|
|
53
62
|
say ""
|
|
63
|
+
|
|
64
|
+
if options[:modern]
|
|
65
|
+
say "Modern views generated! Edit app/views/layouts/faultline/application.html.erb", :green
|
|
66
|
+
say "to match your host app's navigation."
|
|
67
|
+
say ""
|
|
68
|
+
end
|
|
54
69
|
end
|
|
55
70
|
|
|
56
71
|
private
|
|
@@ -2,48 +2,81 @@
|
|
|
2
2
|
|
|
3
3
|
Rails.application.config.to_prepare do
|
|
4
4
|
Faultline.configure do |config|
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# Examples:
|
|
12
|
-
#
|
|
13
|
-
# # Require admin user (Devise / custom auth)
|
|
14
|
-
# config.auth_block = ->(controller) { controller.current_user&.admin? }
|
|
15
|
-
#
|
|
16
|
-
# # Require any logged-in user
|
|
17
|
-
# config.auth_block = ->(controller) { controller.current_user.present? }
|
|
18
|
-
#
|
|
19
|
-
# # HTTP Basic Auth (set FAULTLINE_USER / FAULTLINE_PASSWORD env vars)
|
|
20
|
-
# config.auth_block = ->(controller) {
|
|
21
|
-
# authenticate_or_request_with_http凭据("Faultline") do |username, password|
|
|
22
|
-
# username == ENV["FAULTLINE_USER"] && password == ENV["FAULTLINE_PASSWORD"]
|
|
23
|
-
# end
|
|
24
|
-
# }
|
|
25
|
-
#
|
|
26
|
-
# ⚠️ Without an auth_block, the dashboard is OPEN to anyone.
|
|
27
|
-
# Uncomment and configure one of the examples above before deploying.
|
|
28
|
-
config.auth_block = ->(controller) { true }
|
|
5
|
+
# ─── General ─────────────────────────────────────────────
|
|
6
|
+
# Dashboard title
|
|
7
|
+
# config.application_name = "My App"
|
|
8
|
+
|
|
9
|
+
# Number of exceptions per page
|
|
10
|
+
# config.per_page = 30
|
|
29
11
|
|
|
30
|
-
#
|
|
31
|
-
#
|
|
12
|
+
# ─── Authentication ──────────────────────────────────────
|
|
13
|
+
# Protect the dashboard — only authorized users can access
|
|
14
|
+
# config.auth_block = lambda do |controller|
|
|
15
|
+
# controller.current_user&.admin?
|
|
16
|
+
# end
|
|
17
|
+
|
|
18
|
+
# ─── Exception Data ──────────────────────────────────────
|
|
19
|
+
# Attach additional data to each exception record
|
|
20
|
+
# config.exception_data = lambda do |controller|
|
|
32
21
|
# {
|
|
33
22
|
# user_id: controller.current_user&.id,
|
|
34
23
|
# request_id: controller.request.request_id
|
|
35
24
|
# }
|
|
36
|
-
#
|
|
25
|
+
# end
|
|
37
26
|
|
|
38
|
-
#
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
# ─── Notifications ───────────────────────────────────────
|
|
28
|
+
# Custom callback after exception is created
|
|
29
|
+
# config.after_create = lambda do |exception|
|
|
30
|
+
# SlackNotifier.alert(exception)
|
|
31
|
+
# end
|
|
32
|
+
|
|
33
|
+
# Webhook URLs for POST notifications
|
|
34
|
+
# config.webhooks = ["https://hooks.slack.com/services/xxx"]
|
|
35
|
+
# config.webhook_timeout = 5
|
|
36
|
+
# config.webhook_headers = { "Authorization" => "Bearer token" }
|
|
37
|
+
|
|
38
|
+
# ─── Cleanup ─────────────────────────────────────────────
|
|
39
|
+
# Auto-delete exceptions older than N days
|
|
40
|
+
# config.retention_days = 90
|
|
41
|
+
|
|
42
|
+
# ─── Appearance ──────────────────────────────────────────
|
|
43
|
+
# Theme: "light", "dark", or "auto"
|
|
44
|
+
# config.theme = "auto"
|
|
45
|
+
|
|
46
|
+
# Body CSS class
|
|
47
|
+
# config.body_class = ""
|
|
42
48
|
|
|
43
|
-
#
|
|
44
|
-
|
|
45
|
-
#
|
|
46
|
-
#
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
# ─── Advanced UI ─────────────────────────────────────────
|
|
50
|
+
|
|
51
|
+
# Show stats overview cards on the index page
|
|
52
|
+
# config.show_stats = true
|
|
53
|
+
|
|
54
|
+
# Enable keyboard shortcuts (/, j/k, t, ?, Esc, etc.)
|
|
55
|
+
# config.keyboard_shortcuts = true
|
|
56
|
+
|
|
57
|
+
# Show prev/next navigation in detail view
|
|
58
|
+
# config.enable_navigation = true
|
|
59
|
+
|
|
60
|
+
# Number of backtrace frames before collapsing
|
|
61
|
+
# config.backtrace_limit = 30
|
|
62
|
+
|
|
63
|
+
# Show metadata grid in detail view
|
|
64
|
+
# config.show_metadata = true
|
|
65
|
+
|
|
66
|
+
# Show environment variables in detail view
|
|
67
|
+
# config.show_environment = false
|
|
68
|
+
|
|
69
|
+
# Show request params in detail view
|
|
70
|
+
# config.show_request = true
|
|
71
|
+
|
|
72
|
+
# Page size options for the selector
|
|
73
|
+
# config.page_size_options = [25, 50, 100]
|
|
74
|
+
|
|
75
|
+
# ─── Sidebar Links ───────────────────────────────────────
|
|
76
|
+
# Custom links in the sidebar
|
|
77
|
+
# config.sidebar_links = [
|
|
78
|
+
# { label: "GitHub", url: "https://github.com/myorg/myapp" },
|
|
79
|
+
# { label: "Docs", url: "/docs" }
|
|
80
|
+
# ]
|
|
81
|
+
end
|
|
49
82
|
end
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
|
2
|
+
|
|
3
|
+
export default class extends Controller {
|
|
4
|
+
static targets = ["activity", "shortcutsDialog", "tabs", "tabContent", "exceptionList", "backtraceHidden", "backtraceContent"]
|
|
5
|
+
static values = { shortcuts: Boolean }
|
|
6
|
+
|
|
7
|
+
connect() {
|
|
8
|
+
this.selectedIndex = -1
|
|
9
|
+
this.rows = []
|
|
10
|
+
|
|
11
|
+
this.showActivity = this.showActivity.bind(this)
|
|
12
|
+
this.hideActivity = this.hideActivity.bind(this)
|
|
13
|
+
|
|
14
|
+
document.addEventListener("turbo:before-fetch-request", this.showActivity)
|
|
15
|
+
document.addEventListener("turbo:before-fetch-response", this.hideActivity)
|
|
16
|
+
document.addEventListener("turbo:submit-end", this.hideActivity)
|
|
17
|
+
|
|
18
|
+
if (this.shortcutsValue) {
|
|
19
|
+
this.boundKeydown = this.handleKeydown.bind(this)
|
|
20
|
+
document.addEventListener("keydown", this.boundKeydown)
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
disconnect() {
|
|
25
|
+
document.removeEventListener("turbo:before-fetch-request", this.showActivity)
|
|
26
|
+
document.removeEventListener("turbo:before-fetch-response", this.hideActivity)
|
|
27
|
+
document.removeEventListener("turbo:submit-end", this.hideActivity)
|
|
28
|
+
|
|
29
|
+
if (this.boundKeydown) {
|
|
30
|
+
document.removeEventListener("keydown", this.boundKeydown)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
handleKeydown(event) {
|
|
35
|
+
const tag = event.target.tagName.toLowerCase()
|
|
36
|
+
if (tag === "input" || tag === "textarea" || tag === "select") {
|
|
37
|
+
if (event.key === "Escape") {
|
|
38
|
+
event.target.blur()
|
|
39
|
+
event.preventDefault()
|
|
40
|
+
}
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
switch (event.key) {
|
|
45
|
+
case "/":
|
|
46
|
+
event.preventDefault()
|
|
47
|
+
this.focusSearch()
|
|
48
|
+
break
|
|
49
|
+
case "j":
|
|
50
|
+
case "ArrowDown":
|
|
51
|
+
event.preventDefault()
|
|
52
|
+
this.navigateDown()
|
|
53
|
+
break
|
|
54
|
+
case "k":
|
|
55
|
+
case "ArrowUp":
|
|
56
|
+
event.preventDefault()
|
|
57
|
+
this.navigateUp()
|
|
58
|
+
break
|
|
59
|
+
case "Enter":
|
|
60
|
+
event.preventDefault()
|
|
61
|
+
this.openSelected()
|
|
62
|
+
break
|
|
63
|
+
case "p":
|
|
64
|
+
case "ArrowLeft":
|
|
65
|
+
event.preventDefault()
|
|
66
|
+
this.navigateToPrev()
|
|
67
|
+
break
|
|
68
|
+
case "n":
|
|
69
|
+
case "ArrowRight":
|
|
70
|
+
event.preventDefault()
|
|
71
|
+
this.navigateToNext()
|
|
72
|
+
break
|
|
73
|
+
case "t":
|
|
74
|
+
event.preventDefault()
|
|
75
|
+
this.toggleTheme()
|
|
76
|
+
break
|
|
77
|
+
case "Escape":
|
|
78
|
+
event.preventDefault()
|
|
79
|
+
this.closeDetails(event)
|
|
80
|
+
this.closeShortcuts()
|
|
81
|
+
break
|
|
82
|
+
case "?":
|
|
83
|
+
event.preventDefault()
|
|
84
|
+
this.toggleShortcuts()
|
|
85
|
+
break
|
|
86
|
+
case "1": case "2": case "3": case "4": case "5":
|
|
87
|
+
event.preventDefault()
|
|
88
|
+
this.switchTabByIndex(parseInt(event.key) - 1)
|
|
89
|
+
break
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
focusSearch() {
|
|
94
|
+
const search = this.element.querySelector(".fl-search .fl-input, input[type='search']")
|
|
95
|
+
if (search) {
|
|
96
|
+
search.focus()
|
|
97
|
+
search.select()
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
refreshRows() {
|
|
102
|
+
if (this.hasExceptionListTarget) {
|
|
103
|
+
this.rows = Array.from(this.exceptionListTarget.querySelectorAll("tr[data-url]"))
|
|
104
|
+
} else {
|
|
105
|
+
this.rows = Array.from(this.element.querySelectorAll("tr[data-url]"))
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
navigateDown() {
|
|
110
|
+
this.refreshRows()
|
|
111
|
+
if (this.rows.length === 0) return
|
|
112
|
+
this.selectedIndex = Math.min(this.selectedIndex + 1, this.rows.length - 1)
|
|
113
|
+
this.highlightRow()
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
navigateUp() {
|
|
117
|
+
this.refreshRows()
|
|
118
|
+
if (this.rows.length === 0) return
|
|
119
|
+
this.selectedIndex = Math.max(this.selectedIndex - 1, 0)
|
|
120
|
+
this.highlightRow()
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
highlightRow() {
|
|
124
|
+
this.rows.forEach((row, i) => {
|
|
125
|
+
row.classList.toggle("selected", i === this.selectedIndex)
|
|
126
|
+
})
|
|
127
|
+
const row = this.rows[this.selectedIndex]
|
|
128
|
+
if (row) row.scrollIntoView({ block: "nearest", behavior: "smooth" })
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
openSelected() {
|
|
132
|
+
this.refreshRows()
|
|
133
|
+
if (this.selectedIndex < 0 || this.selectedIndex >= this.rows.length) return
|
|
134
|
+
const row = this.rows[this.selectedIndex]
|
|
135
|
+
if (row.dataset.url) {
|
|
136
|
+
this.selectRow({ currentTarget: row, preventDefault: () => {} })
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
selectRow(event) {
|
|
141
|
+
event.preventDefault()
|
|
142
|
+
const row = event.currentTarget
|
|
143
|
+
const url = row.dataset.url
|
|
144
|
+
if (!url) return
|
|
145
|
+
|
|
146
|
+
this.refreshRows()
|
|
147
|
+
this.rows.forEach(r => r.classList.remove("selected"))
|
|
148
|
+
row.classList.add("selected")
|
|
149
|
+
|
|
150
|
+
const detailPanel = document.getElementById("exception-detail-desktop")
|
|
151
|
+
if (detailPanel) {
|
|
152
|
+
detailPanel.hidden = false
|
|
153
|
+
detailPanel.classList.remove("hidden")
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const frame = document.getElementById("exception-details")
|
|
157
|
+
if (frame) {
|
|
158
|
+
frame.innerHTML = ""
|
|
159
|
+
frame.src = url
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
stopPropagation(event) {
|
|
164
|
+
event.stopPropagation()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
closeDetails(event) {
|
|
168
|
+
event.preventDefault()
|
|
169
|
+
this.refreshRows()
|
|
170
|
+
this.rows.forEach(r => r.classList.remove("selected"))
|
|
171
|
+
this.selectedIndex = -1
|
|
172
|
+
|
|
173
|
+
const detailPanel = document.getElementById("exception-detail-desktop")
|
|
174
|
+
if (detailPanel) {
|
|
175
|
+
detailPanel.hidden = true
|
|
176
|
+
detailPanel.classList.add("hidden")
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const frame = document.getElementById("exception-details")
|
|
180
|
+
if (frame) {
|
|
181
|
+
frame.innerHTML = `
|
|
182
|
+
<div class="text-center py-12">
|
|
183
|
+
<div class="w-10 h-10 rounded-full flex items-center justify-center mx-auto" style="background: var(--fl-bg-secondary)">
|
|
184
|
+
<svg class="w-5 h-5" style="color: var(--fl-text-muted)" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
185
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 14.25v-2.625a3.375 3.375 0 00-3.375-3.375h-1.5A1.125 1.125 0 0113.5 7.125v-1.5a3.375 3.375 0 00-3.375-3.375H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.625c-.621 0-1.125.504-1.125 1.125v17.25c0 .621.504 1.125 1.125 1.125h12.75c.621 0 1.125-.504 1.125-1.125V11.25a9 9 0 00-9-9z" />
|
|
186
|
+
</svg>
|
|
187
|
+
</div>
|
|
188
|
+
<p class="mt-2 text-xs" style="color: var(--fl-text-muted)">Select an exception to view details</p>
|
|
189
|
+
<p class="mt-1 text-xs" style="color: var(--fl-text-muted)">Click a row or press <span class="fl-kbd">↓</span> <span class="fl-kbd">↑</span> to navigate</p>
|
|
190
|
+
</div>
|
|
191
|
+
`
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
switchTab(event) {
|
|
196
|
+
const tabName = event.currentTarget.dataset.flTabParam || event.currentTarget.dataset.flTab
|
|
197
|
+
this.activateTab(tabName)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
switchTabByIndex(index) {
|
|
201
|
+
if (!this.hasTabsTarget) return
|
|
202
|
+
const tabs = this.tabsTarget.querySelectorAll(".fl-tab")
|
|
203
|
+
if (index >= 0 && index < tabs.length) {
|
|
204
|
+
const tabName = tabs[index].dataset.flTabParam || tabs[index].dataset.flTab
|
|
205
|
+
this.activateTab(tabName)
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
activateTab(tabName) {
|
|
210
|
+
if (this.hasTabsTarget) {
|
|
211
|
+
this.tabsTarget.querySelectorAll(".fl-tab").forEach(tab => {
|
|
212
|
+
const isActive = (tab.dataset.flTabParam || tab.dataset.flTab) === tabName
|
|
213
|
+
tab.classList.toggle("active", isActive)
|
|
214
|
+
})
|
|
215
|
+
}
|
|
216
|
+
this.tabContentTargets.forEach(content => {
|
|
217
|
+
const isTarget = content.dataset.flTabContent === tabName
|
|
218
|
+
content.style.display = isTarget ? "" : "none"
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
toggleTheme() {
|
|
223
|
+
const themeController = this.application.getControllerForElementAndIdentifier(
|
|
224
|
+
document.documentElement, "faultline--theme"
|
|
225
|
+
)
|
|
226
|
+
if (themeController) {
|
|
227
|
+
themeController.toggle()
|
|
228
|
+
} else {
|
|
229
|
+
const root = document.documentElement
|
|
230
|
+
const isDark = root.classList.contains("dark")
|
|
231
|
+
root.classList.remove("dark", "light")
|
|
232
|
+
root.classList.add(isDark ? "light" : "dark")
|
|
233
|
+
localStorage.setItem("faultline-theme", isDark ? "light" : "dark")
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
toggleShortcuts() {
|
|
238
|
+
if (!this.hasShortcutsDialogTarget) return
|
|
239
|
+
const isOpen = this.shortcutsDialogTarget.classList.contains("open")
|
|
240
|
+
if (isOpen) { this.closeShortcuts() } else { this.shortcutsDialogTarget.classList.add("open") }
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
closeShortcuts() {
|
|
244
|
+
if (this.hasShortcutsDialogTarget) this.shortcutsDialogTarget.classList.remove("open")
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
navigateToPrev() {
|
|
248
|
+
const prevLink = document.querySelector(".fl-nav-link[href*='logged_exceptions']")
|
|
249
|
+
if (prevLink && prevLink.querySelector(".fl-nav-link-label")?.textContent === "Previous") prevLink.click()
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
navigateToNext() {
|
|
253
|
+
const links = document.querySelectorAll(".fl-nav-link[href*='logged_exceptions']")
|
|
254
|
+
const nextLink = Array.from(links).find(l => l.querySelector(".fl-nav-link-label")?.textContent === "Next")
|
|
255
|
+
if (nextLink) nextLink.click()
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
copyId(event) {
|
|
259
|
+
const id = event.currentTarget.dataset.faultlineIdValue
|
|
260
|
+
if (id) this.copyToClipboard(id, event.currentTarget)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
copyMessage(event) {
|
|
264
|
+
const msg = event.currentTarget.dataset.faultlineMessageValue
|
|
265
|
+
if (msg) this.copyToClipboard(msg, event.currentTarget)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
copyBacktrace(event) {
|
|
269
|
+
const bt = event.currentTarget.dataset.faultlineBacktraceValue
|
|
270
|
+
if (bt) this.copyToClipboard(bt, event.currentTarget)
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
async copyToClipboard(text, button) {
|
|
274
|
+
try {
|
|
275
|
+
await navigator.clipboard.writeText(text)
|
|
276
|
+
} catch {
|
|
277
|
+
const ta = document.createElement("textarea")
|
|
278
|
+
ta.value = text; ta.style.position = "fixed"; ta.style.opacity = "0"
|
|
279
|
+
document.body.appendChild(ta); ta.select(); document.execCommand("copy"); document.body.removeChild(ta)
|
|
280
|
+
}
|
|
281
|
+
const orig = button.innerHTML
|
|
282
|
+
button.classList.add("copied")
|
|
283
|
+
button.innerHTML = `<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" /></svg> Copied!`
|
|
284
|
+
setTimeout(() => { button.classList.remove("copied"); button.innerHTML = orig }, 2000)
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
expandBacktrace(event) {
|
|
288
|
+
event.preventDefault()
|
|
289
|
+
const hidden = this.backtraceHiddenTarget
|
|
290
|
+
if (hidden) {
|
|
291
|
+
hidden.style.display = hidden.style.display === "none" ? "" : "none"
|
|
292
|
+
event.currentTarget.textContent = hidden.style.display === "none"
|
|
293
|
+
? `Show more frames` : "Hide additional frames"
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
submit() {
|
|
298
|
+
this.showActivity()
|
|
299
|
+
const form = this.element.querySelector("form[data-turbo-frame]")
|
|
300
|
+
if (form) form.requestSubmit()
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
debouncedSubmit() {
|
|
304
|
+
clearTimeout(this._debounceTimer)
|
|
305
|
+
this._debounceTimer = setTimeout(() => this.submit(), 400)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
showActivity() { this.activityTarget?.classList.remove("hidden") }
|
|
309
|
+
hideActivity() { this.activityTarget?.classList.add("hidden") }
|
|
310
|
+
}
|
data/lib/generators/faultline/templates/views/faultline/logged_exceptions/_exceptions.html.erb
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
<div id="exceptions-content" class="bg-white rounded-xl border border-gray-200/60 shadow-sm overflow-hidden">
|
|
2
|
+
<% if @exceptions.empty? %>
|
|
3
|
+
<div class="px-6 py-16 text-center">
|
|
4
|
+
<div class="w-10 h-10 rounded-full bg-emerald-50 flex items-center justify-center mx-auto border border-emerald-100">
|
|
5
|
+
<svg class="w-5 h-5 text-emerald-500" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
6
|
+
<path stroke-linecap="round" stroke-linejoin="round" d="M9 12.75L11.25 15 15 9.75M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
|
|
7
|
+
</svg>
|
|
8
|
+
</div>
|
|
9
|
+
<p class="mt-3 text-sm font-medium text-gray-600"><%= t(".empty") %></p>
|
|
10
|
+
<p class="mt-1 text-xs text-gray-400">No exceptions match your filters.</p>
|
|
11
|
+
</div>
|
|
12
|
+
<% else %>
|
|
13
|
+
<%# Table header with count and bulk actions %>
|
|
14
|
+
<div class="px-4 py-2.5 border-b border-gray-100 flex items-center justify-between bg-gray-50/50">
|
|
15
|
+
<div class="flex items-center gap-3">
|
|
16
|
+
<span class="text-xs font-medium text-gray-500">
|
|
17
|
+
<span class="font-semibold text-gray-700"><%= @exceptions.total_entries %></span> exceptions
|
|
18
|
+
<% if filtered? %>
|
|
19
|
+
<span class="text-gray-400">(filtered)</span>
|
|
20
|
+
<% end %>
|
|
21
|
+
</span>
|
|
22
|
+
</div>
|
|
23
|
+
<div class="flex items-center gap-2">
|
|
24
|
+
<%= link_to destroy_all_logged_exceptions_path(params_filters),
|
|
25
|
+
class: "inline-flex items-center gap-1 px-2 py-1 text-[11px] font-medium text-red-600 bg-red-50 border border-red-100 rounded-md hover:bg-red-100 transition-colors",
|
|
26
|
+
data: { turbo_method: :post, turbo_confirm: t(".confirm_delete_visible"), turbo_stream: true } do %>
|
|
27
|
+
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>
|
|
28
|
+
Delete all
|
|
29
|
+
<% end %>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
|
|
33
|
+
<div class="overflow-x-auto">
|
|
34
|
+
<table class="min-w-full">
|
|
35
|
+
<thead>
|
|
36
|
+
<tr class="border-b border-gray-100">
|
|
37
|
+
<th class="px-4 py-2 text-left text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
38
|
+
<%= sort_link @q, :exception_class, "Type", data: { turbo_frame: "exceptions" } %>
|
|
39
|
+
</th>
|
|
40
|
+
<th class="px-4 py-2 text-left text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
41
|
+
<%= sort_link @q, :controller_name, "Source", data: { turbo_frame: "exceptions" } %>
|
|
42
|
+
</th>
|
|
43
|
+
<th class="px-4 py-2 text-left text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
44
|
+
<%= sort_link @q, :action_name, "Action", data: { turbo_frame: "exceptions" } %>
|
|
45
|
+
</th>
|
|
46
|
+
<th class="px-4 py-2 text-left text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
47
|
+
Message
|
|
48
|
+
</th>
|
|
49
|
+
<th class="px-4 py-2 text-left text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
50
|
+
<%= sort_link @q, :created_at, "Time", data: { turbo_frame: "exceptions" } %>
|
|
51
|
+
</th>
|
|
52
|
+
<th class="px-4 py-2 text-right text-[11px] font-semibold text-gray-400 uppercase tracking-wider bg-gray-50/30">
|
|
53
|
+
<span class="sr-only">Actions</span>
|
|
54
|
+
</th>
|
|
55
|
+
</tr>
|
|
56
|
+
</thead>
|
|
57
|
+
<tbody class="divide-y divide-gray-50">
|
|
58
|
+
<% @exceptions.each do |exception| %>
|
|
59
|
+
<tr id="<%= dom_id(exception) %>" class="group hover:bg-indigo-50/30 transition-colors cursor-pointer"
|
|
60
|
+
data-action="click->faultline#selectRow"
|
|
61
|
+
data-url="<%= logged_exception_path(exception) %>">
|
|
62
|
+
<%# Type badge %>
|
|
63
|
+
<td class="px-4 py-2.5 whitespace-nowrap">
|
|
64
|
+
<span class="inline-flex items-center px-2 py-0.5 rounded text-[11px] font-semibold bg-red-50 text-red-700 border border-red-100/80">
|
|
65
|
+
<%= exception.exception_class %>
|
|
66
|
+
</span>
|
|
67
|
+
</td>
|
|
68
|
+
|
|
69
|
+
<%# Source (controller) %>
|
|
70
|
+
<td class="px-4 py-2.5 whitespace-nowrap">
|
|
71
|
+
<div class="flex items-center gap-1.5">
|
|
72
|
+
<span class="w-1.5 h-1.5 rounded-full bg-gray-300 shrink-0"></span>
|
|
73
|
+
<span class="text-xs font-mono text-gray-600"><%= exception.controller_name %></span>
|
|
74
|
+
</div>
|
|
75
|
+
</td>
|
|
76
|
+
|
|
77
|
+
<%# Action %>
|
|
78
|
+
<td class="px-4 py-2.5 whitespace-nowrap text-xs font-mono text-gray-400">
|
|
79
|
+
<%= exception.action_name %>
|
|
80
|
+
</td>
|
|
81
|
+
|
|
82
|
+
<%# Message %>
|
|
83
|
+
<td class="px-4 py-2.5 text-xs text-gray-500 max-w-md truncate">
|
|
84
|
+
<%= link_to exception.message&.truncate(120), logged_exception_path(exception),
|
|
85
|
+
class: "hover:text-indigo-600 transition-colors",
|
|
86
|
+
data: { turbo_frame: "exception-details" } %>
|
|
87
|
+
</td>
|
|
88
|
+
|
|
89
|
+
<%# Time %>
|
|
90
|
+
<td class="px-4 py-2.5 whitespace-nowrap text-[11px] text-gray-400">
|
|
91
|
+
<%= pretty_exception_date(exception) %>
|
|
92
|
+
</td>
|
|
93
|
+
|
|
94
|
+
<%# Actions %>
|
|
95
|
+
<td class="px-4 py-2.5 whitespace-nowrap text-right">
|
|
96
|
+
<%= link_to logged_exception_path(exception),
|
|
97
|
+
class: "opacity-0 group-hover:opacity-100 text-gray-300 hover:text-red-500 transition-all",
|
|
98
|
+
title: "Delete",
|
|
99
|
+
data: { turbo_method: :delete, turbo_confirm: t(".confirm_delete"), turbo_stream: true, action: "click->faultline#stopPropagation" } do %>
|
|
100
|
+
<svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>
|
|
101
|
+
<% end %>
|
|
102
|
+
</td>
|
|
103
|
+
</tr>
|
|
104
|
+
<% end %>
|
|
105
|
+
</tbody>
|
|
106
|
+
</table>
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
<%# Pagination %>
|
|
110
|
+
<% if @exceptions.respond_to?(:total_pages) && @exceptions.total_pages > 1 %>
|
|
111
|
+
<div class="px-4 py-2.5 border-t border-gray-100 flex items-center justify-between bg-gray-50/30">
|
|
112
|
+
<p class="text-[11px] text-gray-400">
|
|
113
|
+
Showing <span class="font-medium text-gray-600"><%= @exceptions.offset + 1 %></span>
|
|
114
|
+
to <span class="font-medium text-gray-600"><%= @exceptions.offset + @exceptions.length %></span>
|
|
115
|
+
of <span class="font-medium text-gray-600"><%= @exceptions.total_entries %></span>
|
|
116
|
+
</p>
|
|
117
|
+
<div>
|
|
118
|
+
<%= will_paginate @exceptions, params: { controller: "logged_exceptions", action: "index" }.merge(params_filters),
|
|
119
|
+
inner_window: 2, outer_window: 1, previous_label: "«", next_label: "»" %>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
<% end %>
|
|
123
|
+
<% end %>
|
|
124
|
+
</div>
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
<div class="p-5 space-y-5">
|
|
2
|
+
<%# Header %>
|
|
3
|
+
<div class="flex items-start justify-between gap-4">
|
|
4
|
+
<div class="min-w-0">
|
|
5
|
+
<div class="flex items-center gap-2 flex-wrap">
|
|
6
|
+
<span class="inline-flex items-center px-2 py-0.5 rounded-md text-xs font-semibold bg-red-50 text-red-700 border border-red-100">
|
|
7
|
+
<%= @exception.exception_class %>
|
|
8
|
+
</span>
|
|
9
|
+
<span class="text-xs text-gray-400">•</span>
|
|
10
|
+
<span class="text-xs text-gray-400 font-mono"><%= @exception.controller_name %>#<%= @exception.action_name %></span>
|
|
11
|
+
</div>
|
|
12
|
+
<p class="mt-2 text-sm text-gray-500">
|
|
13
|
+
<time datetime="<%= @exception.created_at.iso8601 %>"><%= @exception.created_at.strftime("%B %d, %Y at %I:%M %p") %></time>
|
|
14
|
+
<% if @exception.remote_ip.present? %>
|
|
15
|
+
<span class="text-gray-300 mx-1">•</span>
|
|
16
|
+
<span class="font-mono text-gray-400"><%= @exception.remote_ip %></span>
|
|
17
|
+
<% end %>
|
|
18
|
+
</p>
|
|
19
|
+
</div>
|
|
20
|
+
<button type="button"
|
|
21
|
+
class="shrink-0 p-1.5 rounded-lg text-gray-400 hover:text-gray-600 hover:bg-gray-100 transition-colors"
|
|
22
|
+
data-action="click->faultline#closeDetails">
|
|
23
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
|
|
24
|
+
</button>
|
|
25
|
+
</div>
|
|
26
|
+
|
|
27
|
+
<%# Message %>
|
|
28
|
+
<div>
|
|
29
|
+
<h3 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Message</h3>
|
|
30
|
+
<div class="bg-gray-50 rounded-lg border border-gray-100 p-3">
|
|
31
|
+
<pre class="text-sm text-gray-700 whitespace-pre-wrap font-mono leading-relaxed"><%= @exception.message %></pre>
|
|
32
|
+
</div>
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
<%# Request Info %>
|
|
36
|
+
<div>
|
|
37
|
+
<h3 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Request</h3>
|
|
38
|
+
<div class="bg-gray-50 rounded-lg border border-gray-100 p-3">
|
|
39
|
+
<pre class="text-xs text-gray-600 whitespace-pre-wrap font-mono leading-relaxed"><%= pretty_format(@exception.request) %></pre>
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<%# Backtrace %>
|
|
44
|
+
<div>
|
|
45
|
+
<h3 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Backtrace</h3>
|
|
46
|
+
<div class="bg-gray-900 rounded-lg p-3 overflow-auto max-h-80 border border-gray-800">
|
|
47
|
+
<pre class="text-xs text-gray-300 whitespace-pre-wrap font-mono leading-relaxed"><%= @exception.backtrace %></pre>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
|
|
51
|
+
<%# Environment %>
|
|
52
|
+
<div>
|
|
53
|
+
<h3 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">Environment</h3>
|
|
54
|
+
<div class="bg-gray-50 rounded-lg border border-gray-100 p-3 overflow-auto max-h-56">
|
|
55
|
+
<pre class="text-xs text-gray-600 whitespace-pre-wrap font-mono leading-relaxed"><%= pretty_format(@exception.environment) %></pre>
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<%# User Info %>
|
|
60
|
+
<% if @exception.user_info.present? %>
|
|
61
|
+
<div>
|
|
62
|
+
<h3 class="text-[11px] font-semibold text-gray-400 uppercase tracking-wider mb-1.5">User Info</h3>
|
|
63
|
+
<div class="bg-gray-50 rounded-lg border border-gray-100 p-3">
|
|
64
|
+
<pre class="text-xs text-gray-600 whitespace-pre-wrap font-mono leading-relaxed"><%= pretty_format(@exception.user_info) %></pre>
|
|
65
|
+
</div>
|
|
66
|
+
</div>
|
|
67
|
+
<% end %>
|
|
68
|
+
|
|
69
|
+
<%# Actions %>
|
|
70
|
+
<div class="flex items-center justify-between pt-4 border-t border-gray-100">
|
|
71
|
+
<p class="text-xs text-gray-400 font-mono">
|
|
72
|
+
ID: <%= @exception.id %>
|
|
73
|
+
<span class="text-gray-200 mx-1">•</span>
|
|
74
|
+
<time datetime="<%= @exception.created_at.iso8601 %>"><%= @exception.created_at.iso8601 %></time>
|
|
75
|
+
</p>
|
|
76
|
+
<%= link_to logged_exception_path(@exception),
|
|
77
|
+
class: "inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium text-red-600 bg-red-50 border border-red-200 rounded-lg hover:bg-red-100 transition-colors",
|
|
78
|
+
data: { turbo_method: :delete, turbo_confirm: t(".confirm_delete"), turbo_stream: true } do %>
|
|
79
|
+
<svg class="w-3.5 h-3.5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" /></svg>
|
|
80
|
+
Delete
|
|
81
|
+
<% end %>
|
|
82
|
+
</div>
|
|
83
|
+
</div>
|