prosopite 1.0.6 → 1.0.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 77276ce50263c0d9e2e4a9e0c525924ac5810367f036d783197222819f8fb312
4
- data.tar.gz: b43868ebc87b40d97997db1c7a77fb3ee34cb032a76a0b290adb174c8d04c6d3
3
+ metadata.gz: dc0695c895e2f636c3c2a2caa2c4b211cad0f7d57f8bd4842fbc534ba9e55190
4
+ data.tar.gz: 2dcd4426e5b792a58cee89ec601e3388bacc97cb0de57aa3b87dd7600dd6b020
5
5
  SHA512:
6
- metadata.gz: 5fc318b3becb5095f93244d8e23699c27e604c43ba7a3dc489ee3939d19b23e26a47eb4957d6355f28fdaa18fb6ecaa2caf27721a03fcadadefa73a5cbcfec7e
7
- data.tar.gz: e5954aa6aec45c26722f807dcb2fde6aae4c1090d097cc7172a306cdde9639b734d226826fa1d6dcab59a9d22857dc7901978eb4297287ac49b81a63b23ae0e1
6
+ metadata.gz: b2c1c6a4723c44c24ab800fede6c14d49f74ba1c97c4aa60c59a231725e001ca45416abb878331157402582114e144931e39774a9af51fb422d12ba4f668403b
7
+ data.tar.gz: 2175b7c1bd661c5bca41c1263e9a750d63b205e548ef1d2f13ca2aac43c6306eaad3e3bb8420e627ab2576821565311c525e6b51576b4e30431c41420b3b7f0b
@@ -4,7 +4,7 @@ jobs:
4
4
  test:
5
5
  strategy:
6
6
  matrix:
7
- ruby: [2.5, 2.6, 2.7, '3.0', head]
7
+ ruby: [2.5, 2.6, 2.7, '3.0', 3.1, head]
8
8
  runs-on: ubuntu-latest
9
9
  steps:
10
10
  - uses: actions/checkout@v2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prosopite (1.0.6)
4
+ prosopite (1.0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -115,10 +115,34 @@ Or install it yourself as:
115
115
 
116
116
  The preferred type of notifications can be configured with:
117
117
 
118
+ * `Prosopite.raise = true`: Raise warnings as exceptions
118
119
  * `Prosopite.rails_logger = true`: Send warnings to the Rails log
119
120
  * `Prosopite.prosopite_logger = true`: Send warnings to `log/prosopite.log`
120
121
  * `Prosopite.stderr_logger = true`: Send warnings to STDERR
121
- * `Prosopite.raise = true`: Raise warnings as exceptions
122
+ * `Prosopite.custom_logger = my_custom_logger`:
123
+
124
+ ### Custom Logging Configuration
125
+
126
+ You can supply a custom logger with the `Prosopite.custom_logger` setting.
127
+
128
+ This is useful for circumstances where you don't want your logs to be
129
+ highlighted with red, or you want logs sent to a custom location.
130
+
131
+ One common scenario is that you may be generating json logs and sending them to
132
+ Datadog, ELK stack, or similar, and don't want to have to remove the default red
133
+ escaping data from messages sent to the Rails logger, or want to tag them
134
+ differently with your own custom logger.
135
+
136
+ ```ruby
137
+ # Turns off logging with red highlights, but still sends them to the Rails logger
138
+ Prosopite.custom_logger = Rails.logger
139
+ ```
140
+
141
+ ```ruby
142
+ # Use a completely custom logging instance
143
+ Prosopite.custom_logger = MyLoggerClass.new
144
+
145
+ ```
122
146
 
123
147
  ## Development Environment Usage
124
148
 
@@ -128,7 +152,7 @@ Prosopite auto-detection can be enabled on all controllers:
128
152
  class ApplicationController < ActionController::Base
129
153
  unless Rails.env.production?
130
154
  around_action :n_plus_one_detection
131
-
155
+
132
156
  def n_plus_one_detection
133
157
  Prosopite.scan
134
158
  yield
@@ -179,10 +203,10 @@ WARNING: scan/finish should run before/after **each** test and NOT before/after
179
203
 
180
204
  ## Allow list
181
205
 
182
- Ignore notifications for call stacks containing one or more substrings:
206
+ Ignore notifications for call stacks containing one or more substrings / regex:
183
207
 
184
208
  ```ruby
185
- Prosopite.allow_stack_paths = ['substring_in_call_stack']
209
+ Prosopite.allow_stack_paths = ['substring_in_call_stack', /regex/]
186
210
  ```
187
211
 
188
212
  Ignore notifications matching a specific SQL query:
@@ -201,7 +225,7 @@ Prosopite.scan
201
225
  Prosopite.finish
202
226
  ```
203
227
 
204
- or
228
+ or
205
229
 
206
230
  ```ruby
207
231
  Prosopite.scan do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Prosopite
4
- VERSION = "1.0.6"
4
+ VERSION = "1.0.9"
5
5
  end
data/lib/prosopite.rb CHANGED
@@ -8,6 +8,7 @@ module Prosopite
8
8
  :stderr_logger,
9
9
  :rails_logger,
10
10
  :prosopite_logger,
11
+ :custom_logger,
11
12
  :allow_stack_paths,
12
13
  :ignore_queries
13
14
 
@@ -50,7 +51,7 @@ module Prosopite
50
51
  end
51
52
 
52
53
  def resume
53
- tc[:prosopite_scan] = true
54
+ scan
54
55
  end
55
56
 
56
57
  def scan?
@@ -83,7 +84,7 @@ module Prosopite
83
84
 
84
85
  kaller = tc[:prosopite_query_caller][location_key]
85
86
  allow_list = (@allow_stack_paths + DEFAULT_ALLOW_LIST)
86
- is_allowed = kaller.any? { |f| allow_list.any? { |s| f.include?(s) } }
87
+ is_allowed = kaller.any? { |f| allow_list.any? { |s| f.match?(s) } }
87
88
 
88
89
  unless is_allowed
89
90
  queries = tc[:prosopite_query_holder][location_key]
@@ -155,6 +156,7 @@ module Prosopite
155
156
  end
156
157
 
157
158
  def send_notifications
159
+ @custom_logger ||= false
158
160
  @rails_logger ||= false
159
161
  @stderr_logger ||= false
160
162
  @prosopite_logger ||= false
@@ -172,6 +174,8 @@ module Prosopite
172
174
  notifications_str << "\n"
173
175
  end
174
176
 
177
+ @custom_logger.warn(notifications_str) if @custom_logger
178
+
175
179
  Rails.logger.warn(red(notifications_str)) if @rails_logger
176
180
  $stderr.puts(red(notifications_str)) if @stderr_logger
177
181
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prosopite
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mpampis Kostas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-19 00:00:00.000000000 Z
11
+ date: 2022-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry