lograge-sql 2.3.2 → 2.5.0

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: 9111536f41dbfa19e93c81046f55a53e8dd4a25afcca73279b47b30475f75954
4
- data.tar.gz: b43db3a11e0b3dbdfa7bb4f921d95e72ff78d57c3eb8e9f4bc534683f9df945d
3
+ metadata.gz: 3c9d368981a6231cc03eb7b015ab7847fdcc77220c881fc7dd4aa633e74c09b8
4
+ data.tar.gz: aca838791bae71fff0612ac59212e7ccc70597d11cd4916572ad303a858ac811
5
5
  SHA512:
6
- metadata.gz: a0875e72c3883b97291b7a23f9f0f86389b68ff70a2ef6cbfdc8d7dfaae90da8bf2f17e3876e11c8aea105416bdc908519fda25326effacafad02fb46ee9c47c
7
- data.tar.gz: f59abb9c350112083eeeb2dd1d28ee37d75295542ae441f0cdf275192560e334f1f7bf2f147e19d05036016ca174683bebc42b1a6bcd22a8eb095574e42d5338
6
+ metadata.gz: e0f1485cbf50c44020d64730a9f7f06843f9105b5c5cb07319285185a299b02bdd669661a8ed644531feb97d61f3e7da39eea2b8918d2f16ed6c53b6cff9d506
7
+ data.tar.gz: cf39a5e5af70750a6908e33d33993228000b1681d8ffb978f9fa9c64bda68e065c0017e4fafbdac389957d903b075e57a332788ac77a4db90218ce4a614e2605
data/README.md CHANGED
@@ -45,6 +45,20 @@ Rails.application.configure do
45
45
  end
46
46
  ```
47
47
 
48
+ ### Filtering sql queries by name
49
+
50
+ You can filter out queries using the `query_name_denylist` configuration.
51
+ This takes an array of regular expressions to match against the query name. If the query name matches any of the regular expressions, it will be ignored. By default, `lograge-sql` ignores queries named `SCHEMA` and queries from the `SolidCable` namespace.
52
+ If you are using Solid Cable in your project, be careful when removing this default value as it will cause a [memory leak](https://github.com/iMacTia/lograge-sql/issues/59).
53
+
54
+ ```ruby
55
+ # config/initializers/lograge.rb
56
+ Rails.application.configure do
57
+ # Defaults is [/\ASCHEMA\z/, /\ASolidCable::/]
58
+ config.lograge_sql.query_name_denylist << /\AEXACT NAME TO IGNORE\z/
59
+ end
60
+ ```
61
+
48
62
  ### Output Customization
49
63
 
50
64
  By default, the format is a string concatenation of the query name, the query duration and the query itself joined by `\n` newline:
@@ -33,7 +33,7 @@ module Lograge
33
33
  end
34
34
 
35
35
  def valid?(event)
36
- return false if event.payload[:name] == 'SCHEMA'
36
+ return false if event.payload[:name]&.match?(Regexp.union(Lograge::Sql.query_name_denylist))
37
37
 
38
38
  # Only store SQL events if `event.duration` is greater than the configured +min_duration+
39
39
  # No need to check if +min_duration+ is present before as it defaults to 0
@@ -3,6 +3,6 @@
3
3
  module Lograge
4
4
  module Sql
5
5
  # Gem version
6
- VERSION = '2.3.2'
6
+ VERSION = '2.5.0'
7
7
  end
8
8
  end
data/lib/lograge/sql.rb CHANGED
@@ -15,6 +15,8 @@ module Lograge
15
15
  attr_accessor :min_duration_ms
16
16
  # Filter SQL query
17
17
  attr_accessor :query_filter
18
+ # Filter wich SQL queries to store
19
+ attr_accessor :query_name_denylist
18
20
 
19
21
  # Initialise configuration with fallback to default values
20
22
  def setup(config)
@@ -22,6 +24,7 @@ module Lograge
22
24
  Lograge::Sql.extract_event = config.extract_event || default_extract_event
23
25
  Lograge::Sql.min_duration_ms = config.min_duration_ms || 0
24
26
  Lograge::Sql.query_filter = config.query_filter
27
+ Lograge::Sql.query_name_denylist = config.query_name_denylist || [/\ASCHEMA\z/, /\ASolidCable::/]
25
28
 
26
29
  # Disable existing ActiveRecord logging
27
30
  unsubscribe_log_subscribers unless config.keep_default_active_record_log
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lograge-sql
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Giuffrida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-18 00:00:00.000000000 Z
11
+ date: 2024-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '5'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.2'
22
+ version: '8.1'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '5'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.2'
32
+ version: '8.1'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: lograge
35
35
  requirement: !ruby/object:Gem::Requirement