log_sanity 2.1.1 → 2.2.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: 2aad47580de71bc5f808b70557881ed7134404f150e8b8c7893f33c3ef660327
4
- data.tar.gz: 3cba5122b91fa6163d3d9e5e8b6cb537a577136e670ace442c30297a8ddd8a50
3
+ metadata.gz: 334adfd10ad13c52b7a3e24973adb808447737f1f7099576aac44b21c871df46
4
+ data.tar.gz: dcfab6f923a4d6ccce9d57f57c10c8b883ff4729a2e36fa977be03c58f631487
5
5
  SHA512:
6
- metadata.gz: 1112c2fdc532170c33d4288806f369f077ccc1f627345bbdb5d593a051480cd5417d875c475c545096261ec095e3d1c89ab9fe25174c1ae02c9f94e1f0f96d27
7
- data.tar.gz: f653ecf13c53ed5b8a5a3a44af7353461488a6bc6c5cac9060fcc692d5c0ceb9528b1547054dfa8285e91f369bce1281e081cc6a0961cc45a36fa33773d9cec2
6
+ metadata.gz: 0776a645c92e2fcc3bb17c1df01b364c5ad070690c388628060461a8a1c1880cee6bfa5605eb53d24443bbdec853407bb3f9ebafbc76a7b799cd3278bf3c2eb9
7
+ data.tar.gz: a964344a187aaccc49c3eda2dddd8f17077541b9b836eb836507cda7980c608818510e3e6330df1d51602d27fe7e7c1b46b50d456e92b4296033173a77167dde
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ #### 2.2.0
2
+
3
+ - Add DB query counts for ActiveRecord 7.2
4
+ Only real queries are reported; cached queries are excluded
5
+
6
+ #### 2.1.2
7
+
8
+ - In ActiveJob logs, output gid:// when available instead of using .to_json
9
+
1
10
  #### 2.1.1
2
11
 
3
12
  - Report correct request method when Rails handles an exception
data/Gemfile.lock CHANGED
@@ -1,104 +1,100 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- log_sanity (2.1.1)
5
- rails (>= 7.1.2, < 7.2)
4
+ log_sanity (2.2.0)
5
+ rails (>= 7.1.2, < 7.3)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- actioncable (7.1.2)
11
- actionpack (= 7.1.2)
12
- activesupport (= 7.1.2)
10
+ actioncable (7.2.1)
11
+ actionpack (= 7.2.1)
12
+ activesupport (= 7.2.1)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
15
15
  zeitwerk (~> 2.6)
16
- actionmailbox (7.1.2)
17
- actionpack (= 7.1.2)
18
- activejob (= 7.1.2)
19
- activerecord (= 7.1.2)
20
- activestorage (= 7.1.2)
21
- activesupport (= 7.1.2)
22
- mail (>= 2.7.1)
23
- net-imap
24
- net-pop
25
- net-smtp
26
- actionmailer (7.1.2)
27
- actionpack (= 7.1.2)
28
- actionview (= 7.1.2)
29
- activejob (= 7.1.2)
30
- activesupport (= 7.1.2)
31
- mail (~> 2.5, >= 2.5.4)
32
- net-imap
33
- net-pop
34
- net-smtp
16
+ actionmailbox (7.2.1)
17
+ actionpack (= 7.2.1)
18
+ activejob (= 7.2.1)
19
+ activerecord (= 7.2.1)
20
+ activestorage (= 7.2.1)
21
+ activesupport (= 7.2.1)
22
+ mail (>= 2.8.0)
23
+ actionmailer (7.2.1)
24
+ actionpack (= 7.2.1)
25
+ actionview (= 7.2.1)
26
+ activejob (= 7.2.1)
27
+ activesupport (= 7.2.1)
28
+ mail (>= 2.8.0)
35
29
  rails-dom-testing (~> 2.2)
36
- actionpack (7.1.2)
37
- actionview (= 7.1.2)
38
- activesupport (= 7.1.2)
30
+ actionpack (7.2.1)
31
+ actionview (= 7.2.1)
32
+ activesupport (= 7.2.1)
39
33
  nokogiri (>= 1.8.5)
40
34
  racc
41
- rack (>= 2.2.4)
35
+ rack (>= 2.2.4, < 3.2)
42
36
  rack-session (>= 1.0.1)
43
37
  rack-test (>= 0.6.3)
44
38
  rails-dom-testing (~> 2.2)
45
39
  rails-html-sanitizer (~> 1.6)
46
- actiontext (7.1.2)
47
- actionpack (= 7.1.2)
48
- activerecord (= 7.1.2)
49
- activestorage (= 7.1.2)
50
- activesupport (= 7.1.2)
40
+ useragent (~> 0.16)
41
+ actiontext (7.2.1)
42
+ actionpack (= 7.2.1)
43
+ activerecord (= 7.2.1)
44
+ activestorage (= 7.2.1)
45
+ activesupport (= 7.2.1)
51
46
  globalid (>= 0.6.0)
52
47
  nokogiri (>= 1.8.5)
53
- actionview (7.1.2)
54
- activesupport (= 7.1.2)
48
+ actionview (7.2.1)
49
+ activesupport (= 7.2.1)
55
50
  builder (~> 3.1)
56
51
  erubi (~> 1.11)
57
52
  rails-dom-testing (~> 2.2)
58
53
  rails-html-sanitizer (~> 1.6)
59
- activejob (7.1.2)
60
- activesupport (= 7.1.2)
54
+ activejob (7.2.1)
55
+ activesupport (= 7.2.1)
61
56
  globalid (>= 0.3.6)
62
- activemodel (7.1.2)
63
- activesupport (= 7.1.2)
64
- activerecord (7.1.2)
65
- activemodel (= 7.1.2)
66
- activesupport (= 7.1.2)
57
+ activemodel (7.2.1)
58
+ activesupport (= 7.2.1)
59
+ activerecord (7.2.1)
60
+ activemodel (= 7.2.1)
61
+ activesupport (= 7.2.1)
67
62
  timeout (>= 0.4.0)
68
- activestorage (7.1.2)
69
- actionpack (= 7.1.2)
70
- activejob (= 7.1.2)
71
- activerecord (= 7.1.2)
72
- activesupport (= 7.1.2)
63
+ activestorage (7.2.1)
64
+ actionpack (= 7.2.1)
65
+ activejob (= 7.2.1)
66
+ activerecord (= 7.2.1)
67
+ activesupport (= 7.2.1)
73
68
  marcel (~> 1.0)
74
- activesupport (7.1.2)
69
+ activesupport (7.2.1)
75
70
  base64
76
71
  bigdecimal
77
- concurrent-ruby (~> 1.0, >= 1.0.2)
72
+ concurrent-ruby (~> 1.0, >= 1.3.1)
78
73
  connection_pool (>= 2.2.5)
79
74
  drb
80
75
  i18n (>= 1.6, < 2)
76
+ logger (>= 1.4.2)
81
77
  minitest (>= 5.1)
82
- mutex_m
83
- tzinfo (~> 2.0)
78
+ securerandom (>= 0.3)
79
+ tzinfo (~> 2.0, >= 2.0.5)
84
80
  base64 (0.2.0)
85
- bigdecimal (3.1.4)
86
- builder (3.2.4)
87
- concurrent-ruby (1.2.2)
81
+ bigdecimal (3.1.8)
82
+ builder (3.3.0)
83
+ concurrent-ruby (1.3.4)
88
84
  connection_pool (2.4.1)
89
85
  crass (1.0.6)
90
86
  date (3.3.4)
91
- drb (2.2.0)
92
- ruby2_keywords
93
- erubi (1.12.0)
87
+ drb (2.2.1)
88
+ erubi (1.13.0)
94
89
  globalid (1.2.1)
95
90
  activesupport (>= 6.1)
96
- i18n (1.14.1)
91
+ i18n (1.14.6)
97
92
  concurrent-ruby (~> 1.0)
98
- io-console (0.6.0)
99
- irb (1.9.1)
100
- rdoc
101
- reline (>= 0.3.8)
93
+ io-console (0.7.2)
94
+ irb (1.14.0)
95
+ rdoc (>= 4.0.0)
96
+ reline (>= 0.4.2)
97
+ logger (1.6.1)
102
98
  loofah (2.22.0)
103
99
  crass (~> 1.0.2)
104
100
  nokogiri (>= 1.12.0)
@@ -107,30 +103,28 @@ GEM
107
103
  net-imap
108
104
  net-pop
109
105
  net-smtp
110
- marcel (1.0.2)
106
+ marcel (1.0.4)
111
107
  mini_mime (1.1.5)
112
- minitest (5.20.0)
113
- mutex_m (0.2.0)
114
- net-imap (0.4.6)
108
+ minitest (5.25.1)
109
+ net-imap (0.4.16)
115
110
  date
116
111
  net-protocol
117
112
  net-pop (0.1.2)
118
- net-protocol
119
113
  net-protocol (0.2.2)
120
114
  timeout
121
- net-smtp (0.4.0)
115
+ net-smtp (0.5.0)
122
116
  net-protocol
123
- nio4r (2.6.1)
124
- nokogiri (1.15.5-arm64-darwin)
117
+ nio4r (2.7.3)
118
+ nokogiri (1.16.7-arm64-darwin)
125
119
  racc (~> 1.4)
126
- nokogiri (1.15.5-x86_64-darwin)
120
+ nokogiri (1.16.7-x86_64-darwin)
127
121
  racc (~> 1.4)
128
- nokogiri (1.15.5-x86_64-linux)
122
+ nokogiri (1.16.7-x86_64-linux)
129
123
  racc (~> 1.4)
130
- psych (5.1.1.1)
124
+ psych (5.1.2)
131
125
  stringio
132
- racc (1.7.3)
133
- rack (3.0.8)
126
+ racc (1.8.1)
127
+ rack (3.1.7)
134
128
  rack-session (2.0.0)
135
129
  rack (>= 3.0.0)
136
130
  rack-test (2.1.0)
@@ -138,20 +132,20 @@ GEM
138
132
  rackup (2.1.0)
139
133
  rack (>= 3)
140
134
  webrick (~> 1.8)
141
- rails (7.1.2)
142
- actioncable (= 7.1.2)
143
- actionmailbox (= 7.1.2)
144
- actionmailer (= 7.1.2)
145
- actionpack (= 7.1.2)
146
- actiontext (= 7.1.2)
147
- actionview (= 7.1.2)
148
- activejob (= 7.1.2)
149
- activemodel (= 7.1.2)
150
- activerecord (= 7.1.2)
151
- activestorage (= 7.1.2)
152
- activesupport (= 7.1.2)
135
+ rails (7.2.1)
136
+ actioncable (= 7.2.1)
137
+ actionmailbox (= 7.2.1)
138
+ actionmailer (= 7.2.1)
139
+ actionpack (= 7.2.1)
140
+ actiontext (= 7.2.1)
141
+ actionview (= 7.2.1)
142
+ activejob (= 7.2.1)
143
+ activemodel (= 7.2.1)
144
+ activerecord (= 7.2.1)
145
+ activestorage (= 7.2.1)
146
+ activesupport (= 7.2.1)
153
147
  bundler (>= 1.15.0)
154
- railties (= 7.1.2)
148
+ railties (= 7.2.1)
155
149
  rails-dom-testing (2.2.0)
156
150
  activesupport (>= 5.0.0)
157
151
  minitest
@@ -159,30 +153,31 @@ GEM
159
153
  rails-html-sanitizer (1.6.0)
160
154
  loofah (~> 2.21)
161
155
  nokogiri (~> 1.14)
162
- railties (7.1.2)
163
- actionpack (= 7.1.2)
164
- activesupport (= 7.1.2)
165
- irb
156
+ railties (7.2.1)
157
+ actionpack (= 7.2.1)
158
+ activesupport (= 7.2.1)
159
+ irb (~> 1.13)
166
160
  rackup (>= 1.0.0)
167
161
  rake (>= 12.2)
168
162
  thor (~> 1.0, >= 1.2.2)
169
163
  zeitwerk (~> 2.6)
170
- rake (13.1.0)
171
- rdoc (6.6.0)
164
+ rake (13.2.1)
165
+ rdoc (6.7.0)
172
166
  psych (>= 4.0.0)
173
- reline (0.4.0)
167
+ reline (0.5.10)
174
168
  io-console (~> 0.5)
175
- ruby2_keywords (0.0.5)
176
- stringio (3.0.9)
177
- thor (1.3.0)
169
+ securerandom (0.3.1)
170
+ stringio (3.1.1)
171
+ thor (1.3.2)
178
172
  timeout (0.4.1)
179
173
  tzinfo (2.0.6)
180
174
  concurrent-ruby (~> 1.0)
175
+ useragent (0.16.10)
181
176
  webrick (1.8.1)
182
177
  websocket-driver (0.7.6)
183
178
  websocket-extensions (>= 0.1.0)
184
179
  websocket-extensions (0.1.5)
185
- zeitwerk (2.6.12)
180
+ zeitwerk (2.6.18)
186
181
 
187
182
  PLATFORMS
188
183
  arm64-darwin
@@ -193,4 +188,4 @@ DEPENDENCIES
193
188
  log_sanity!
194
189
 
195
190
  BUNDLED WITH
196
- 2.4.10
191
+ 2.5.11
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2017-2023 thomas morgan
1
+ Copyright 2017-2024 thomas morgan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -23,14 +23,24 @@ module LogSanity
23
23
  end
24
24
 
25
25
  durations = {'total' => event.duration.round}
26
+ queries = {}
26
27
  additions = ::ActionController::Base.log_process_action(payload)
27
28
  additions.each do |add|
28
29
  if add =~ /^([^:]+):?\s*([0-9.]+)(ms)?/
29
30
  ms = $2.to_f.round
30
- durations[$1.downcase] = ms if ms > 0
31
+ name = $1.downcase
32
+ durations[name] = ms if ms > 0
33
+ end
34
+ if name and add =~ /[^0-9]([0-9]+) quer/
35
+ q_real = $1.to_i
36
+ if q_real > 0 and add =~ /[^0-9]([0-9]+) cached/
37
+ q_real -= $1.to_i # exclude cached queries
38
+ end
39
+ queries[name] = q_real if q_real > 0
31
40
  end
32
41
  end
33
42
 
43
+ log 'queries', queries if queries.any?
34
44
  log 'duration', durations
35
45
  log 'status', status
36
46
  end
@@ -12,7 +12,7 @@ module LogSanity
12
12
  'id' => job.job_id,
13
13
  'queue' => job.queue_name
14
14
  }
15
- e['params'] = job.arguments if job.arguments.any?
15
+ e['params'] = format_args(job.arguments) if job.arguments.any?
16
16
  if error = event.payload[:exception_object] || job.enqueue_error
17
17
  e['error'] = error
18
18
  elsif event.payload[:aborted]
@@ -33,7 +33,7 @@ module LogSanity
33
33
  'queue' => job.queue_name,
34
34
  'start_at' => job.scheduled_at
35
35
  }
36
- e['params'] = job.arguments if job.arguments.any?
36
+ e['params'] = format_args(job.arguments) if job.arguments.any?
37
37
  if error = event.payload[:exception_object] || job.enqueue_error
38
38
  e['error'] = error
39
39
  elsif event.payload[:aborted]
@@ -65,7 +65,7 @@ module LogSanity
65
65
  # 'id' => job.job_id,
66
66
  # 'queue' => job.queue_name,
67
67
  # }
68
- # e['params'] = job.arguments if job.arguments.any?
68
+ # e['params'] = format_args(job.arguments) if job.arguments.any?
69
69
  # e
70
70
  # end
71
71
  # end
@@ -81,7 +81,7 @@ module LogSanity
81
81
  'queue' => job.queue_name,
82
82
  'duration' => {'total' => event.duration.round}
83
83
  }
84
- e['params'] = job.arguments if job.arguments.any?
84
+ e['params'] = format_args(job.arguments) if job.arguments.any?
85
85
  if error = event.payload[:exception_object]
86
86
  e['error'] = error
87
87
  elsif event.payload[:aborted]
@@ -91,6 +91,22 @@ module LogSanity
91
91
  end
92
92
  end
93
93
 
94
+
95
+ private
96
+
97
+ def format_args(arg)
98
+ case arg
99
+ when Hash
100
+ arg.transform_values{|val| format_args val }
101
+ when Array
102
+ arg.map{|val| format_args val }
103
+ when GlobalID::Identification
104
+ arg.to_global_id rescue "#{arg.class}(#{arg.try(:id)})"
105
+ else
106
+ arg
107
+ end
108
+ end
109
+
94
110
  end
95
111
  end
96
112
  end
@@ -1,3 +1,3 @@
1
1
  module LogSanity
2
- VERSION = '2.1.1'
2
+ VERSION = '2.2.0'
3
3
  end
data/log_sanity.gemspec CHANGED
@@ -17,5 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
18
  s.require_paths = ["lib"]
19
19
 
20
- s.add_dependency 'rails', '>= 7.1.2', '< 7.2'
20
+ s.add_dependency 'rails', '>= 7.1.2', '< 7.3'
21
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log_sanity
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - thomas morgan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-27 00:00:00.000000000 Z
11
+ date: 2024-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 7.1.2
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7.2'
22
+ version: '7.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 7.1.2
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7.2'
32
+ version: '7.3'
33
33
  description: LogSanity - Bring sanity to Rails logs by reducing verbosity, using json
34
34
  output, and more.
35
35
  email:
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  - !ruby/object:Gem::Version
122
122
  version: '0'
123
123
  requirements: []
124
- rubygems_version: 3.4.10
124
+ rubygems_version: 3.5.11
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: LogSanity - Bring sanity to Rails logs