solid_errors 0.3.3 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 042e023f7ef8a19fb20f44b9c6cf044af997a58eab4c15c23030896798738a48
4
- data.tar.gz: 7e02ed9572becd8e6563c1f089ca710e4186704b6312edb453b5b12741e2679a
3
+ metadata.gz: a2eee8c990cddbb820d0e26419c5a08d163552840313b5468d15c9590d07f831
4
+ data.tar.gz: 578aac9f9b1f58003b50cd1482cedbda43804e54ee1349a52fd47f79acc51f18
5
5
  SHA512:
6
- metadata.gz: d71b734df7c89c784a01d005fbe41eb31ad7bd07e51aa2e8d1ef7049aeabee94888d9d93c0440445e40d6a179bbb0a60082b81fe7517d576688b1a05a49e5c1b
7
- data.tar.gz: 01ee124e9d940f36a0c2b9079bb173ea25fdfb0912991483dd35188984e28ce8a390d8fd9e2c2d10a33ac65e48b203c35eb6fb46a3160a722399dee63605badd
6
+ metadata.gz: 5ec9d232d8e0b622cfa099b2c2fd16232681b65ca24825411caa95cf91680da02099a0ddb6ce2901ce3857d9489cf2d0cef410aef8609f6cc54ff2ff19821afd
7
+ data.tar.gz: 61a0e98f22ee56313cb7867452b0ae42945a204cb5736edec59aa429d103d4b136ba223bf28bc7d54f85bb7c00b483d2557e41473c76f38fdff915577c9004a6
data/README.md CHANGED
@@ -30,22 +30,28 @@ Solid Errors is a DB-based, app-internal exception tracker for Rails application
30
30
  ## Installation
31
31
 
32
32
  Install the gem and add to the application's Gemfile by executing:
33
-
34
- $ bundle add solid_errors
33
+ ```bash
34
+ $ bundle add solid_errors
35
+ ```
35
36
 
36
37
  If bundler is not being used to manage dependencies, install the gem by executing:
37
-
38
- $ gem install solid_errors
38
+ ```bash
39
+ $ gem install solid_errors
40
+ ```
39
41
 
40
42
  After installing the gem, run the installer:
41
-
42
- $ rails generate solid_errors:install
43
+ ```bash
44
+ $ rails generate solid_errors:install
45
+ ```
43
46
 
44
47
  This will copy the required migration over to your app.
45
48
 
46
- Then mount the engine in your config/routes.rb file
47
-
48
- mount SolidErrors::Engine, at: "/solid_errors"
49
+ Then mount the engine in your `config/routes.rb` file:
50
+ ```ruby
51
+ authenticate :user, -> (user) { user.admin? } do
52
+ mount SolidErrors::Engine, at: "/solid_errors"
53
+ end
54
+ ```
49
55
 
50
56
  > [!NOTE]
51
57
  > Be sure to [secure the dashboard](#authentication) in production.
@@ -56,6 +62,8 @@ All exceptions are recorded automatically. No additional code required.
56
62
 
57
63
  Please consult the [official guides](https://guides.rubyonrails.org/error_reporting.html) for an introduction to the error reporting API.
58
64
 
65
+ There are intentionally few features; you can view and resolve errors. That’s it. The goal is to provide a simple, lightweight, and performant solution for tracking exceptions in your Rails application. If you need more features, you should probably use a 3rd party service like [Honeybadger](https://www.honeybadger.io/), whose MIT-licensed [Ruby agent gem](https://github.com/honeybadger-io/honeybadger-ruby) provided a couple of critical pieces of code for this project.
66
+
59
67
  ### Configuration
60
68
 
61
69
  You can configure Solid Errors via the Rails configuration object, under the `solid_errors` key. Currently, only 3 configuration options are available:
@@ -1,4 +1,5 @@
1
1
  module SolidErrors
2
+ # adapted from: https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/backtrace.rb
2
3
  class Backtrace
3
4
  # Holder for an Array of Backtrace::Line instances.
4
5
  attr_reader :lines, :application_lines
@@ -1,4 +1,5 @@
1
1
  module SolidErrors
2
+ # adapted from: https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/backtrace.rb
2
3
  class BacktraceLine
3
4
  # Backtrace line regexp (optionally allowing leading X: for windows support).
4
5
  INPUT_FORMAT = %r{^((?:[a-zA-Z]:)?[^:]+):(\d+)(?::in `([^']+)')?$}.freeze
@@ -28,7 +29,7 @@ module SolidErrors
28
29
  attr_reader :file
29
30
  attr_reader :number
30
31
  attr_reader :method
31
- attr_reader :filtered_file, :filtered_number, :filtered_method
32
+ attr_reader :filtered_file, :filtered_number, :filtered_method, :unparsed_line
32
33
 
33
34
  # Parses a single line of a given backtrace
34
35
  #
@@ -46,13 +47,14 @@ module SolidErrors
46
47
 
47
48
  file, number, method = match[1], match[2], match[3]
48
49
  filtered_args = [fmatch[1], fmatch[2], fmatch[3]]
49
- new(file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
50
+ new(unparsed_line, file, number, method, *filtered_args, opts.fetch(:source_radius, 2))
50
51
  end
51
52
  end
52
53
 
53
- def initialize(file, number, method, filtered_file = file,
54
+ def initialize(unparsed_line, file, number, method, filtered_file = file,
54
55
  filtered_number = number, filtered_method = method,
55
56
  source_radius = 2)
57
+ self.unparsed_line = unparsed_line
56
58
  self.filtered_file = filtered_file
57
59
  self.filtered_number = filtered_number
58
60
  self.filtered_method = filtered_method
@@ -86,7 +88,7 @@ module SolidErrors
86
88
 
87
89
  private
88
90
 
89
- attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method
91
+ attr_writer :file, :number, :method, :filtered_file, :filtered_number, :filtered_method, :unparsed_line
90
92
 
91
93
  attr_accessor :source_radius
92
94
 
@@ -1093,6 +1093,13 @@
1093
1093
  <%= content_for?(:content) ? yield(:content) : yield %>
1094
1094
  </main>
1095
1095
 
1096
+ <footer class="container mx-auto py-4 mt-24 text-base flex justify-between items-center border-t">
1097
+ <p>
1098
+ <code><strong>Solid</strong> <em>Errors</em></code>&nbsp;&nbsp;|&nbsp;
1099
+ Made by <a href="https://twitter.com/fractaledmind" class="text-blue-500 hover:underline decoration-blue-500">@fractaledmind</a> and <a href="https://github.com/fractaledmind/solid_errors/graphs/contributors" class="text-blue-500 hover:underline decoration-blue-500">friends</a>! Want to help? It's <a href="https://github.com/fractaledmind/solid_errors" class="text-blue-500 hover:underline decoration-blue-500">open source</a>!
1100
+ </p>
1101
+ </footer>
1102
+
1096
1103
  <div class="fixed top-0 left-0 right-0 text-center py-2">
1097
1104
  <% if notice.present? %>
1098
1105
  <p id="notice"
@@ -27,9 +27,13 @@
27
27
  <% backtrace.lines.each_with_index do |line, i| %>
28
28
  <%= tag.details open: line.application? || i.zero? do %>
29
29
  <summary class="hover:bg-gray-50 px-2 py-1 rounded cursor-pointer">
30
- <span class="text-gray-500"><%= File.dirname(line.filtered_file) %>/</span><span class="text-blue-500 font-medium"><%= File.basename(line.filtered_file) %></span>:<span class="text-gray-900 font-medium"><%= line.filtered_number %></span>
31
- <span class="text-gray-500">in</span>
32
- <code class="text-green-500 font-medium"><%= line.filtered_method %></code>
30
+ <% if line.filtered_file %>
31
+ <span class="text-gray-500"><%= File.dirname(line.filtered_file) %>/</span><span class="text-blue-500 font-medium"><%= File.basename(line.filtered_file) %></span>:<span class="text-gray-900 font-medium"><%= line.filtered_number %></span>
32
+ <span class="text-gray-500">in</span>
33
+ <code class="text-green-500 font-medium"><%= line.filtered_method %></code>
34
+ <% else %>
35
+ <span class="text-gray-500"><%= line.unparsed_line %>
36
+ <% end %>
33
37
  </summary>
34
38
  <div><pre class="flex overflow-auto rounded-b-lg bg-slate-800 p-4 text-sm leading-normal text-white sm:rounded-t-lg"><code class="flex flex-col min-h-full min-w-content px-0"><% line.source.each do |n, code| %>
35
39
  <div class="line"><span class="mr-2 text-right select-none text-gray-600"><%= n %></span><span><%= code %></span></div>
@@ -3,9 +3,9 @@
3
3
  class CreateSolidErrorsTables < ActiveRecord::Migration<%= migration_version %>
4
4
  def change
5
5
  create_table :solid_errors do |t|
6
- t.string :exception_class, null: false
6
+ t.string :exception_class, null: false, limit: 200
7
7
  t.string :message, null: false
8
- t.string :severity, null: false
8
+ t.string :severity, null: false, limit: 25
9
9
  t.string :source
10
10
  t.datetime :resolved_at, index: true
11
11
 
@@ -80,7 +80,7 @@ module SolidErrors
80
80
  end
81
81
 
82
82
  def sanitize_string(string)
83
- string.gsub!(/#<(.*?):0x.*?>/, '#<\1>') # remove object_id
83
+ string = string.gsub(/#<(.*?):0x.*?>/, '#<\1>') # remove object_id
84
84
  return string unless string.respond_to?(:size) && string.size > MAX_STRING_SIZE
85
85
  string[0...MAX_STRING_SIZE] + TRUNCATED
86
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidErrors
4
- VERSION = "0.3.3"
4
+ VERSION = "0.3.5"
5
5
  end
data/lib/solid_errors.rb CHANGED
@@ -7,20 +7,20 @@ require_relative "solid_errors/engine"
7
7
 
8
8
  module SolidErrors
9
9
  mattr_accessor :connects_to
10
- mattr_accessor :username
11
- mattr_accessor :password
10
+ mattr_writer :username
11
+ mattr_writer :password
12
12
 
13
13
  class << self
14
14
  # use method instead of attr_accessor to ensure
15
15
  # this works if variable set after SolidErrors is loaded
16
16
  def username
17
- @username ||= ENV["SOLIDERRORS_USERNAME"]
17
+ @username ||= ENV["SOLIDERRORS_USERNAME"] || @@username
18
18
  end
19
19
 
20
20
  # use method instead of attr_accessor to ensure
21
21
  # this works if variable set after SolidErrors is loaded
22
22
  def password
23
- @password ||= ENV["SOLIDERRORS_PASSWORD"]
23
+ @password ||= ENV["SOLIDERRORS_PASSWORD"] || @@password
24
24
  end
25
25
  end
26
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_errors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Margheim
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-28 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -55,6 +55,7 @@ files:
55
55
  - app/models/solid_errors/occurrence.rb
56
56
  - app/models/solid_errors/record.rb
57
57
  - app/views/layouts/solid_errors/application.html.erb
58
+ - app/views/solid_errors/error_mailer/error_occurred.text.erb
58
59
  - app/views/solid_errors/errors/_actions.html.erb
59
60
  - app/views/solid_errors/errors/_error.html.erb
60
61
  - app/views/solid_errors/errors/index.html.erb