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
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
<% page_title t(".title") %>
|
|
2
|
+
|
|
3
|
+
<div class="space-y-4" data-controller="faultline">
|
|
4
|
+
<%# Header with stats %>
|
|
5
|
+
<div class="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3">
|
|
6
|
+
<div>
|
|
7
|
+
<h1 class="text-xl font-bold text-gray-900 tracking-tight"><%= t(".title") %></h1>
|
|
8
|
+
<p class="mt-0.5 text-xs text-gray-400"><%= t(".subtitle") %></p>
|
|
9
|
+
</div>
|
|
10
|
+
<div class="flex items-center gap-2">
|
|
11
|
+
<span class="inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium rounded-full bg-red-50 text-red-700 border border-red-100">
|
|
12
|
+
<span class="w-1.5 h-1.5 rounded-full bg-red-500 animate-pulse"></span>
|
|
13
|
+
<%= Faultline::LoggedException.count %> total
|
|
14
|
+
</span>
|
|
15
|
+
<%= button_to t(".clear_history"), clear_logged_exceptions_path, method: :post,
|
|
16
|
+
class: "inline-flex items-center gap-1 px-2.5 py-1 text-xs font-medium text-gray-500 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 hover:text-red-600 transition-colors",
|
|
17
|
+
form: { data: { turbo_stream: true } },
|
|
18
|
+
data: { turbo_confirm: t(".confirm_clear") } %>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<%# Filters Bar %>
|
|
23
|
+
<div class="bg-white rounded-xl border border-gray-200/60 shadow-sm">
|
|
24
|
+
<div class="px-4 py-3 border-b border-gray-100 flex items-center gap-2">
|
|
25
|
+
<svg class="w-4 h-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3c2.755 0 5.455.232 8.083.678.533.09.917.556.917 1.096v1.044a2.25 2.25 0 01-.659 1.591l-5.432 5.432a2.25 2.25 0 00-.659 1.591v2.927a2.25 2.25 0 01-1.244 2.013L9.75 21v-6.568a2.25 2.25 0 00-.659-1.591L3.659 7.409A2.25 2.25 0 013 5.818V4.774c0-.54.384-1.006.917-1.096A48.32 48.32 0 0112 3z" /></svg>
|
|
26
|
+
<span class="text-xs font-semibold text-gray-500 uppercase tracking-wider">Filters</span>
|
|
27
|
+
<% if filtered? %>
|
|
28
|
+
<%= link_to "Clear", logged_exceptions_path, class: "ml-auto text-xs text-indigo-600 hover:text-indigo-800 font-medium" %>
|
|
29
|
+
<% end %>
|
|
30
|
+
</div>
|
|
31
|
+
|
|
32
|
+
<%= search_form_for @q, url: query_logged_exceptions_path, data: { turbo_frame: "exceptions" } do |f| %>
|
|
33
|
+
<div class="px-4 py-3 flex flex-wrap items-end gap-3">
|
|
34
|
+
<%# Exception Class Select %>
|
|
35
|
+
<div class="flex-1 min-w-[160px]">
|
|
36
|
+
<label class="block text-[11px] font-medium text-gray-400 uppercase tracking-wider mb-1">Exception</label>
|
|
37
|
+
<%= f.select :exception_class_cont,
|
|
38
|
+
options_for_select(@exception_names.map { |n| [n, n] }, params.dig(:q, :exception_class_cont)),
|
|
39
|
+
{ include_blank: "All exceptions" },
|
|
40
|
+
class: "block w-full rounded-lg border-gray-200 bg-gray-50/50 text-sm py-2 pl-3 pr-8 focus:border-indigo-500 focus:bg-white focus:ring-1 focus:ring-indigo-500/20 appearance-none cursor-pointer",
|
|
41
|
+
data: { action: "change->faultline#submit" } %>
|
|
42
|
+
</div>
|
|
43
|
+
|
|
44
|
+
<%# Controller Select %>
|
|
45
|
+
<div class="flex-1 min-w-[160px]">
|
|
46
|
+
<label class="block text-[11px] font-medium text-gray-400 uppercase tracking-wider mb-1">Controller</label>
|
|
47
|
+
<%= f.select :controller_name_cont,
|
|
48
|
+
options_for_select(@controller_actions.map { |a| [a, a] }, params.dig(:q, :controller_name_cont)),
|
|
49
|
+
{ include_blank: "All controllers" },
|
|
50
|
+
class: "block w-full rounded-lg border-gray-200 bg-gray-50/50 text-sm py-2 pl-3 pr-8 focus:border-indigo-500 focus:bg-white focus:ring-1 focus:ring-indigo-500/20 appearance-none cursor-pointer",
|
|
51
|
+
data: { action: "change->faultline#submit" } %>
|
|
52
|
+
</div>
|
|
53
|
+
|
|
54
|
+
<%# Time Range Select %>
|
|
55
|
+
<div class="flex-1 min-w-[160px]">
|
|
56
|
+
<label class="block text-[11px] font-medium text-gray-400 uppercase tracking-wider mb-1">Time Range</label>
|
|
57
|
+
<%= select_tag :date_ranges_filter,
|
|
58
|
+
options_for_select([
|
|
59
|
+
["All time", ""],
|
|
60
|
+
["Today", "1"],
|
|
61
|
+
["Last 3 days", "3"],
|
|
62
|
+
["Last 7 days", "7"],
|
|
63
|
+
["Last 30 days", "30"]
|
|
64
|
+
], params[:date_ranges_filter]),
|
|
65
|
+
class: "block w-full rounded-lg border-gray-200 bg-gray-50/50 text-sm py-2 pl-3 pr-8 focus:border-indigo-500 focus:bg-white focus:ring-1 focus:ring-indigo-500/20 appearance-none cursor-pointer",
|
|
66
|
+
data: { action: "change->faultline#submit" } %>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<%# Message Search %>
|
|
70
|
+
<div class="flex-1 min-w-[200px]">
|
|
71
|
+
<label class="block text-[11px] font-medium text-gray-400 uppercase tracking-wider mb-1">Search</label>
|
|
72
|
+
<%= f.search_field :message_cont,
|
|
73
|
+
placeholder: "Search messages...",
|
|
74
|
+
class: "block w-full rounded-lg border-gray-200 bg-gray-50/50 text-sm py-2 px-3 focus:border-indigo-500 focus:bg-white focus:ring-1 focus:ring-indigo-500/20",
|
|
75
|
+
data: { action: "input->faultline#debouncedSubmit" } %>
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
<div class="flex gap-2">
|
|
79
|
+
<%= f.submit "Apply", class: "px-4 py-2 text-sm font-medium text-white bg-indigo-600 rounded-lg hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors" %>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
<% end %>
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<%# Content %>
|
|
86
|
+
<div class="space-y-4">
|
|
87
|
+
<%# Activity indicator %>
|
|
88
|
+
<div id="activity" data-faultline-target="activity" class="rounded-lg bg-indigo-50 border border-indigo-200 p-3 flex items-center gap-3" role="status" aria-live="polite" hidden>
|
|
89
|
+
<svg class="animate-spin h-4 w-4 text-indigo-500 shrink-0" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
|
|
90
|
+
<circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
|
|
91
|
+
<path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
|
|
92
|
+
</svg>
|
|
93
|
+
<p class="text-sm font-medium text-indigo-700"><%= t(".loading") %></p>
|
|
94
|
+
</div>
|
|
95
|
+
|
|
96
|
+
<%# Exception Details Panel %>
|
|
97
|
+
<%= turbo_frame_tag "exception-details", class: "bg-white rounded-xl border border-gray-200/60 shadow-sm" do %>
|
|
98
|
+
<div class="text-center py-12">
|
|
99
|
+
<div class="w-10 h-10 rounded-full bg-gray-50 flex items-center justify-center mx-auto border border-gray-100">
|
|
100
|
+
<svg class="w-5 h-5 text-gray-300" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
101
|
+
<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" />
|
|
102
|
+
</svg>
|
|
103
|
+
</div>
|
|
104
|
+
<p class="mt-2 text-xs text-gray-400">Select an exception to view details</p>
|
|
105
|
+
</div>
|
|
106
|
+
<% end %>
|
|
107
|
+
|
|
108
|
+
<%# Exceptions List %>
|
|
109
|
+
<%= turbo_frame_tag "exceptions" do %>
|
|
110
|
+
<%= render "exceptions" %>
|
|
111
|
+
<% end %>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" class="h-full" data-controller="faultline--theme" data-faultline--theme-theme-value="<%= Faultline.configuration.theme %>">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title><%= content_for?(:title) ? yield(:title) : Faultline.configuration.application_name || "Faultline" %></title>
|
|
8
|
+
|
|
9
|
+
<%# Load host app stylesheet first (provides Tailwind utilities if used) %>
|
|
10
|
+
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" if defined?(Propshaft) %>
|
|
11
|
+
<%= stylesheet_link_tag "faultline/dashboard", "data-turbo-track": "reload" %>
|
|
12
|
+
|
|
13
|
+
<% if respond_to?(:javascript_importmap_tags) %>
|
|
14
|
+
<%= javascript_importmap_tags %>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<% if respond_to?(:turbo_refreshes_with) %>
|
|
18
|
+
<%= turbo_refreshes_with method: :morph, scroll: :preserve %>
|
|
19
|
+
<% end %>
|
|
20
|
+
<%= csrf_meta_tags %>
|
|
21
|
+
</head>
|
|
22
|
+
<body class="h-full <%= Faultline.configuration.body_class %>">
|
|
23
|
+
<div class="min-h-full flex">
|
|
24
|
+
|
|
25
|
+
<%# Sidebar %>
|
|
26
|
+
<aside class="fl-sidebar">
|
|
27
|
+
<div class="fl-sidebar-logo">
|
|
28
|
+
<%= link_to root_path, class: "flex items-center gap-2.5" do %>
|
|
29
|
+
<div class="fl-logo-icon">⚡</div>
|
|
30
|
+
<span class="fl-logo-text"><%= Faultline.configuration.application_name || "Faultline" %></span>
|
|
31
|
+
<% end %>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<nav class="fl-sidebar-nav">
|
|
35
|
+
<%= link_to root_path,
|
|
36
|
+
class: "fl-nav-item #{request.path == faultline.root_path ? 'active' : ''}" do %>
|
|
37
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6zM3.75 15.75A2.25 2.25 0 016 13.5h2.25a2.25 2.25 0 012.25 2.25V18a2.25 2.25 0 01-2.25 2.25H6A2.25 2.25 0 013.75 18v-2.25zM13.5 6a2.25 2.25 0 012.25-2.25H18A2.25 2.25 0 0120.25 6v2.25A2.25 2.25 0 0118 10.5h-2.25a2.25 2.25 0 01-2.25-2.25V6zM13.5 15.75a2.25 2.25 0 012.25-2.25H18a2.25 2.25 0 012.25 2.25V18A2.25 2.25 0 0118 20.25h-2.25A2.25 2.25 0 0113.5 18v-2.25z" /></svg>
|
|
38
|
+
Dashboard
|
|
39
|
+
<% end %>
|
|
40
|
+
|
|
41
|
+
<%= link_to feed_logged_exceptions_path(format: :rss),
|
|
42
|
+
class: "fl-nav-item" do %>
|
|
43
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12.75 19.5v-.75a7.5 7.5 0 00-7.5-7.5H4.5m0-6.75h.75c7.87 0 14.25 6.38 14.25 14.25v.75M6 18.75a.375.375 0 11-.75 0 .375.375 0 01.75 0z" /></svg>
|
|
44
|
+
RSS Feed
|
|
45
|
+
<% end %>
|
|
46
|
+
|
|
47
|
+
<% Faultline.configuration.sidebar_links.each do |link| %>
|
|
48
|
+
<%= link_to link[:url],
|
|
49
|
+
class: "fl-nav-item",
|
|
50
|
+
target: link[:target] || "_self" do %>
|
|
51
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" /></svg>
|
|
52
|
+
<%= link[:label] %>
|
|
53
|
+
<% end %>
|
|
54
|
+
<% end %>
|
|
55
|
+
</nav>
|
|
56
|
+
|
|
57
|
+
<div class="fl-sidebar-footer">
|
|
58
|
+
v<%= Faultline::VERSION %> · <%= Faultline::LoggedException.count %> exceptions
|
|
59
|
+
</div>
|
|
60
|
+
</aside>
|
|
61
|
+
|
|
62
|
+
<%# Main Content %>
|
|
63
|
+
<div class="flex-1 flex flex-col min-w-0">
|
|
64
|
+
<header class="fl-topbar">
|
|
65
|
+
<div class="flex items-center gap-3">
|
|
66
|
+
<button type="button" class="lg:hidden fl-icon-btn" data-action="click->faultline--sidebar#toggle">
|
|
67
|
+
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5" /></svg>
|
|
68
|
+
</button>
|
|
69
|
+
<span class="text-sm font-semibold lg:hidden"><%= Faultline.configuration.application_name || "Faultline" %></span>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<div class="flex items-center gap-1.5">
|
|
73
|
+
<button type="button"
|
|
74
|
+
class="fl-icon-btn"
|
|
75
|
+
data-action="click->faultline--theme#toggle"
|
|
76
|
+
title="Toggle theme">
|
|
77
|
+
<svg class="w-4 h-4 block dark:hidden" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" /></svg>
|
|
78
|
+
<svg class="w-4 h-4 hidden dark:block" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" /></svg>
|
|
79
|
+
</button>
|
|
80
|
+
|
|
81
|
+
<% if main_app.respond_to?(:root_path) %>
|
|
82
|
+
<%= link_to main_app.root_path,
|
|
83
|
+
class: "fl-icon-btn",
|
|
84
|
+
title: "Back to app" do %>
|
|
85
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M13.5 6H5.25A2.25 2.25 0 003 8.25v10.5A2.25 2.25 0 005.25 21h10.5A2.25 2.25 0 0018 18.75V10.5m-10.5 6L21 3m0 0h-5.25M21 3v5.25" /></svg>
|
|
86
|
+
<% end %>
|
|
87
|
+
<% end %>
|
|
88
|
+
</div>
|
|
89
|
+
</header>
|
|
90
|
+
|
|
91
|
+
<% if notice.present? %>
|
|
92
|
+
<div class="mx-4 sm:mx-6 mt-4">
|
|
93
|
+
<div class="fl-alert fl-alert-success">
|
|
94
|
+
<svg class="w-5 h-5 shrink-0" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd" /></svg>
|
|
95
|
+
<p class="text-sm font-medium"><%= notice %></p>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
<% end %>
|
|
99
|
+
|
|
100
|
+
<% if alert.present? %>
|
|
101
|
+
<div class="mx-4 sm:mx-6 mt-4">
|
|
102
|
+
<div class="fl-alert fl-alert-error">
|
|
103
|
+
<svg class="w-5 h-5 shrink-0" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" /></svg>
|
|
104
|
+
<p class="text-sm font-medium"><%= alert %></p>
|
|
105
|
+
</div>
|
|
106
|
+
</div>
|
|
107
|
+
<% end %>
|
|
108
|
+
|
|
109
|
+
<main class="flex-1 overflow-y-auto p-4 sm:p-6">
|
|
110
|
+
<%= yield %>
|
|
111
|
+
</main>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
|
|
115
|
+
<div class="fl-overlay" data-faultline--sidebar-target="overlay" data-action="click->faultline--sidebar#close"></div>
|
|
116
|
+
<div class="fl-mobile-sidebar" data-faultline--sidebar-target="drawer">
|
|
117
|
+
<div class="fl-sidebar-logo">
|
|
118
|
+
<span class="fl-logo-text"><%= Faultline.configuration.application_name || "Faultline" %></span>
|
|
119
|
+
<button type="button" class="fl-icon-btn" data-action="click->faultline--sidebar#close">
|
|
120
|
+
<svg class="w-5 h-5" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" /></svg>
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
<nav class="fl-sidebar-nav">
|
|
124
|
+
<%= link_to root_path, class: "fl-nav-item" do %>
|
|
125
|
+
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6A2.25 2.25 0 016 3.75h2.25A2.25 2.25 0 0110.5 6v2.25a2.25 2.25 0 01-2.25 2.25H6a2.25 2.25 0 01-2.25-2.25V6z" /></svg>
|
|
126
|
+
Dashboard
|
|
127
|
+
<% end %>
|
|
128
|
+
</nav>
|
|
129
|
+
</div>
|
|
130
|
+
|
|
131
|
+
<%= turbo_frame_tag :remote_modal, target: :_top %>
|
|
132
|
+
</body>
|
|
133
|
+
</html>
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
namespace :faultline do
|
|
4
|
+
desc "Delete exceptions older than the configured retention period"
|
|
5
|
+
task cleanup: :environment do
|
|
6
|
+
require "faultline/cleanup"
|
|
7
|
+
count = Faultline::Cleanup.run
|
|
8
|
+
if count
|
|
9
|
+
puts "✓ Cleaned up #{count} old exceptions."
|
|
10
|
+
else
|
|
11
|
+
puts "⚠ No retention_days configured. Set config.retention_days in your initializer."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Show faultline statistics"
|
|
16
|
+
task stats: :environment do
|
|
17
|
+
require "faultline/logger"
|
|
18
|
+
|
|
19
|
+
stats = Faultline::Logger.stats
|
|
20
|
+
|
|
21
|
+
puts ""
|
|
22
|
+
puts " ⚡ Faultline v#{Faultline::VERSION}"
|
|
23
|
+
puts " ─────────────────────────────────────"
|
|
24
|
+
puts " Total exceptions: #{stats[:total]}"
|
|
25
|
+
puts ""
|
|
26
|
+
|
|
27
|
+
if stats[:top_exceptions].any?
|
|
28
|
+
puts " Top exceptions:"
|
|
29
|
+
stats[:top_exceptions].each do |klass, count|
|
|
30
|
+
puts " #{klass.ljust(40)} #{count}"
|
|
31
|
+
end
|
|
32
|
+
puts ""
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
if stats[:by_controller].any?
|
|
36
|
+
puts " By controller:"
|
|
37
|
+
stats[:by_controller].sort_by { |_, v| -v }.first(10).each do |ctrl, count|
|
|
38
|
+
puts " #{ctrl.to_s.ljust(40)} #{count}"
|
|
39
|
+
end
|
|
40
|
+
puts ""
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "Tail faultline logs in real-time"
|
|
45
|
+
task tail: :environment do
|
|
46
|
+
log_file = Faultline.configuration.log_file
|
|
47
|
+
if log_file.blank?
|
|
48
|
+
puts "⚠ No log_file configured. Set config.log_file in your initializer."
|
|
49
|
+
puts " Example: config.log_file = 'log/faultline.log'"
|
|
50
|
+
next
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
puts "Tailing #{log_file}... (Ctrl+C to stop)"
|
|
54
|
+
puts ""
|
|
55
|
+
|
|
56
|
+
IO.popen(["tail", "-f", log_file]) do |io|
|
|
57
|
+
while (line = io.gets)
|
|
58
|
+
begin
|
|
59
|
+
entry = JSON.parse(line)
|
|
60
|
+
level = entry["level"].to_s.upcase.ljust(5)
|
|
61
|
+
ts = entry["timestamp"].to_s.sub(/T/, " ").sub(/\+.*/, "")
|
|
62
|
+
msg = entry["message"]
|
|
63
|
+
cls = entry["exception_class"]
|
|
64
|
+
ctrl = entry["controller"]
|
|
65
|
+
|
|
66
|
+
line_out = "[#{level}] #{ts}"
|
|
67
|
+
line_out += " #{cls}:" if cls.present?
|
|
68
|
+
line_out += " #{msg}"
|
|
69
|
+
line_out += " [#{ctrl["class"]}##{ctrl["action"]}]" if ctrl.present?
|
|
70
|
+
|
|
71
|
+
puts line_out
|
|
72
|
+
rescue JSON::ParserError
|
|
73
|
+
puts line
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
desc "Export exceptions to JSON"
|
|
80
|
+
task export: :environment do
|
|
81
|
+
require "json"
|
|
82
|
+
|
|
83
|
+
output_file = ENV.fetch("OUTPUT", "faultline_export.json")
|
|
84
|
+
since = ENV["SINCE"] ? Time.parse(ENV["SINCE"]) : nil
|
|
85
|
+
|
|
86
|
+
scope = Faultline::LoggedException.order(created_at: :desc)
|
|
87
|
+
scope = scope.where("created_at >= ?", since) if since.present?
|
|
88
|
+
|
|
89
|
+
data = scope.map do |e|
|
|
90
|
+
{
|
|
91
|
+
id: e.id,
|
|
92
|
+
exception_class: e.exception_class,
|
|
93
|
+
controller_name: e.controller_name,
|
|
94
|
+
action_name: e.action_name,
|
|
95
|
+
message: e.message,
|
|
96
|
+
backtrace: e.backtrace,
|
|
97
|
+
environment: e.environment,
|
|
98
|
+
request: e.request,
|
|
99
|
+
user_info: e.user_info,
|
|
100
|
+
remote_ip: e.remote_ip,
|
|
101
|
+
user_agent: e.user_agent,
|
|
102
|
+
created_at: e.created_at.iso8601,
|
|
103
|
+
updated_at: e.updated_at.iso8601
|
|
104
|
+
}
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
File.write(output_file, JSON.pretty_generate(data))
|
|
108
|
+
puts "✓ Exported #{data.size} exceptions to #{output_file}"
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
desc "Test webhook configuration"
|
|
112
|
+
task test_webhook: :environment do
|
|
113
|
+
require "faultline/notifications"
|
|
114
|
+
|
|
115
|
+
config = Faultline.configuration
|
|
116
|
+
if config.webhooks.empty?
|
|
117
|
+
puts "⚠ No webhooks configured. Set config.webhooks in your initializer."
|
|
118
|
+
next
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
puts "Testing webhooks..."
|
|
122
|
+
config.webhooks.each do |url|
|
|
123
|
+
print " #{url}... "
|
|
124
|
+
begin
|
|
125
|
+
uri = URI(url)
|
|
126
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
127
|
+
http.use_ssl = uri.scheme == "https"
|
|
128
|
+
http.open_timeout = 5
|
|
129
|
+
http.read_timeout = 5
|
|
130
|
+
|
|
131
|
+
request = Net::HTTP::Post.new(uri)
|
|
132
|
+
request["Content-Type"] = "application/json"
|
|
133
|
+
config.webhook_headers.each { |k, v| request[k] = v }
|
|
134
|
+
request.body = { event: "test", message: "Faultline webhook test", timestamp: Time.current.iso8601 }.to_json
|
|
135
|
+
|
|
136
|
+
response = http.request(request)
|
|
137
|
+
if response.is_a?(Net::HTTPSuccess)
|
|
138
|
+
puts "✓ (#{response.code})"
|
|
139
|
+
else
|
|
140
|
+
puts "✗ (#{response.code} #{response.message})"
|
|
141
|
+
end
|
|
142
|
+
rescue StandardError => e
|
|
143
|
+
puts "✗ (#{e.message})"
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: faultline-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tamiru Hailu
|
|
@@ -99,11 +99,14 @@ files:
|
|
|
99
99
|
- app/assets/config/faultline_manifest.js
|
|
100
100
|
- app/assets/javascripts/faultline/application.js
|
|
101
101
|
- app/assets/stylesheets/faultline/application.css
|
|
102
|
+
- app/assets/stylesheets/faultline/dashboard.css
|
|
102
103
|
- app/controllers/faultline/application_controller.rb
|
|
103
104
|
- app/controllers/faultline/logged_exceptions_controller.rb
|
|
104
105
|
- app/helpers/faultline/application_helper.rb
|
|
105
106
|
- app/helpers/faultline/logged_exceptions_helper.rb
|
|
106
107
|
- app/javascript/controllers/faultline_controller.js
|
|
108
|
+
- app/javascript/faultline/controllers/sidebar_controller.js
|
|
109
|
+
- app/javascript/faultline/controllers/theme_controller.js
|
|
107
110
|
- app/jobs/faultline/application_job.rb
|
|
108
111
|
- app/mailers/faultline/application_mailer.rb
|
|
109
112
|
- app/models/faultline/application_record.rb
|
|
@@ -130,13 +133,23 @@ files:
|
|
|
130
133
|
- faultline-rails.gemspec
|
|
131
134
|
- lib/faultline-rails.rb
|
|
132
135
|
- lib/faultline.rb
|
|
136
|
+
- lib/faultline/cleanup.rb
|
|
133
137
|
- lib/faultline/configuration.rb
|
|
134
138
|
- lib/faultline/engine.rb
|
|
139
|
+
- lib/faultline/logger.rb
|
|
140
|
+
- lib/faultline/notifications.rb
|
|
135
141
|
- lib/faultline/ransack_config.rb
|
|
136
142
|
- lib/faultline/version.rb
|
|
143
|
+
- lib/generators/faultline/customize_generator.rb
|
|
137
144
|
- lib/generators/faultline/install_generator.rb
|
|
138
145
|
- lib/generators/faultline/templates/faultline.rb
|
|
146
|
+
- lib/generators/faultline/templates/javascript/controllers/faultline_controller.js
|
|
139
147
|
- lib/generators/faultline/templates/migration.rb
|
|
148
|
+
- lib/generators/faultline/templates/views/faultline/logged_exceptions/_exceptions.html.erb
|
|
149
|
+
- lib/generators/faultline/templates/views/faultline/logged_exceptions/_show.html.erb
|
|
150
|
+
- lib/generators/faultline/templates/views/faultline/logged_exceptions/index.html.erb
|
|
151
|
+
- lib/generators/faultline/templates/views/layouts/faultline/application.html.erb
|
|
152
|
+
- lib/tasks/faultline.rake
|
|
140
153
|
- lib/tasks/faultline_tasks.rake
|
|
141
154
|
homepage: https://github.com/tamiru/faultline-rails
|
|
142
155
|
licenses:
|
|
@@ -146,6 +159,7 @@ metadata:
|
|
|
146
159
|
homepage_uri: https://github.com/tamiru/faultline-rails
|
|
147
160
|
source_code_uri: https://github.com/tamiru/faultline-rails/tree/main
|
|
148
161
|
changelog_uri: https://github.com/tamiru/faultline-rails/blob/main/CHANGELOG.md
|
|
162
|
+
funding_uri: https://github.com/sponsors/tamiru
|
|
149
163
|
rdoc_options: []
|
|
150
164
|
require_paths:
|
|
151
165
|
- lib
|