active_record-mod_sql_log_subscriber 0.1.2 → 0.2.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 -14
- data/active_record-mod_sql_log_subscriber.gemspec +3 -3
- data/lib/active_record/mod_sql_log_subscriber.rb +6 -4
- metadata +18 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e3c2cd58b98dcfc754e549f0bad82d88bb205156a2de6cca67bd11c3a9f22b2
|
4
|
+
data.tar.gz: f59d6077a9d32213d0a72e59c3ecd2d4b836d1d496a020fe18f4c4872ba4d82a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5377d7fdfa5c94a4f547d83a1b065fd0029a087de732dfc99c61b151b17f7c2f95071ee55b21976801d5cb447c24f83a3aed3d154f89676e19e5a662fa4014b7
|
7
|
+
data.tar.gz: ce485ef3a8579f30fe45cf388d3bda511223047d8c286208a1a60353b925ecd2b6041415421226fb1f778f6e5465c07c15355de912361d276348c63f6d626322
|
data/README.md
CHANGED
@@ -47,7 +47,7 @@ Or install it yourself as:
|
|
47
47
|
|
48
48
|
## Usage
|
49
49
|
|
50
|
-
Create a file under`config/initializer`, configure log subscriber,
|
50
|
+
Create a file under`config/initializer`, configure log subscriber,
|
51
51
|
and attach to :active_record namespace.
|
52
52
|
|
53
53
|
```
|
@@ -97,12 +97,12 @@ $ bin/console
|
|
97
97
|
# I, [2019-02-05T11:04:07.492610 #42019] INFO -- : commit transaction
|
98
98
|
|
99
99
|
> user = User.last # => no log
|
100
|
-
> user.
|
100
|
+
> user.update!(name: 'new name')
|
101
101
|
# => I, [2019-02-05T11:04:52.971503 #42019] INFO -- : begin transaction
|
102
102
|
# I, [2019-02-05T11:04:52.973071 #42019] INFO -- : UPDATE "users" SET "name" = ?, "updated_at" = ? WHERE "users"."id" = ? ["new name", "2019-02-20 05:00:37.983816", 2]
|
103
103
|
# I, [2019-02-05T11:04:52.974081 #42019] INFO -- : commit transaction
|
104
104
|
|
105
|
-
> user.destroy
|
105
|
+
> user.destroy!
|
106
106
|
# => I, [2019-02-05T11:05:13.765564 #42019] INFO -- : begin transaction
|
107
107
|
# I, [2019-02-05T11:05:13.775460 #42019] INFO -- : DELETE FROM "users" WHERE "users"."id" = ? [2]
|
108
108
|
# I, [2019-02-05T11:05:13.776722 #42019] INFO -- : commit transaction
|
@@ -134,7 +134,7 @@ This is useful in development/test env because duplicated sql logs are written i
|
|
134
134
|
::ActiveRecord::ModSqlLogSubscriber.configure do |config|
|
135
135
|
config.disable = false # enabled
|
136
136
|
config.disable = true # disabled
|
137
|
-
|
137
|
+
|
138
138
|
config.disable = ::ActiveRecord::Base.logger.debug? # Recommended
|
139
139
|
end
|
140
140
|
```
|
@@ -167,11 +167,11 @@ You can add/change/remove target SQL statements.
|
|
167
167
|
```
|
168
168
|
::ActiveRecord::ModSqlLogSubscriber.configure do |config|
|
169
169
|
# Add MERGE SQL
|
170
|
-
config.target_statements << 'merge'
|
171
|
-
|
170
|
+
config.target_statements << 'merge'
|
171
|
+
|
172
172
|
# Remove BEGIN SQL
|
173
173
|
config.target_stagements.delete('begin')
|
174
|
-
|
174
|
+
|
175
175
|
# Orverwite your target statements
|
176
176
|
config.target_statements = %w(insert update delete)
|
177
177
|
end
|
@@ -179,18 +179,18 @@ end
|
|
179
179
|
|
180
180
|
## Development
|
181
181
|
|
182
|
-
After checking out the repo, run `bin/setup` to install dependencies.
|
182
|
+
After checking out the repo, run `bin/setup` to install dependencies.
|
183
183
|
You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
184
184
|
|
185
|
-
To install this gem onto your local machine, run `bundle exec rake install`.
|
186
|
-
To release a new version, update the version number in `mod_sql_log_subscriber.r`,
|
187
|
-
and then run `bundle exec rake release`, which will create a git tag for the version,
|
185
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
186
|
+
To release a new version, update the version number in `mod_sql_log_subscriber.r`,
|
187
|
+
and then run `bundle exec rake release`, which will create a git tag for the version,
|
188
188
|
push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
189
189
|
|
190
190
|
## Contributing
|
191
191
|
|
192
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/ryu39/active_record-mod_sql_log_subscriber.
|
193
|
-
This project is intended to be a safe, welcoming space for collaboration,
|
192
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ryu39/active_record-mod_sql_log_subscriber.
|
193
|
+
This project is intended to be a safe, welcoming space for collaboration,
|
194
194
|
and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
195
195
|
|
196
196
|
## License
|
@@ -199,5 +199,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
199
199
|
|
200
200
|
## Code of Conduct
|
201
201
|
|
202
|
-
Everyone interacting in the ActiveRecord::ModSqlLogSubscriber project’s codebases, issue trackers,
|
202
|
+
Everyone interacting in the ActiveRecord::ModSqlLogSubscriber project’s codebases, issue trackers,
|
203
203
|
chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ryu39/active_record-mod_sql_log_subscriber/blob/master/CODE_OF_CONDUCT.md).
|
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_runtime_dependency "activesupport", '>= 5.1.5'
|
30
30
|
spec.add_runtime_dependency "activerecord", '>= 5.1.5'
|
31
31
|
|
32
|
-
spec.add_development_dependency "bundler"
|
33
|
-
spec.add_development_dependency "rake"
|
32
|
+
spec.add_development_dependency "bundler"
|
33
|
+
spec.add_development_dependency "rake"
|
34
34
|
spec.add_development_dependency "rspec"
|
35
|
-
spec.add_development_dependency "sqlite3"
|
35
|
+
spec.add_development_dependency "sqlite3"
|
36
36
|
end
|
@@ -10,7 +10,7 @@ module ActiveRecord
|
|
10
10
|
class ModSqlLogSubscriber < ::ActiveRecord::LogSubscriber
|
11
11
|
include ActiveSupport::Configurable
|
12
12
|
|
13
|
-
VERSION = "0.
|
13
|
+
VERSION = "0.2.0"
|
14
14
|
|
15
15
|
config_accessor :disable, :log_level, :log_format, :target_statements
|
16
16
|
|
@@ -31,8 +31,10 @@ module ActiveRecord
|
|
31
31
|
return if IGNORE_PAYLOAD_NAMES.include?(payload[:name])
|
32
32
|
return unless target_sql_checker.match?(sql)
|
33
33
|
|
34
|
-
|
35
|
-
|
34
|
+
send(self.log_level) do
|
35
|
+
binds = type_casted_binds(payload[:type_casted_binds])
|
36
|
+
formatter.call(sql, binds)
|
37
|
+
end
|
36
38
|
end
|
37
39
|
|
38
40
|
private
|
@@ -45,7 +47,7 @@ module ActiveRecord
|
|
45
47
|
@formatter ||=
|
46
48
|
case self.log_format
|
47
49
|
when :text
|
48
|
-
->(sql, binds) { binds
|
50
|
+
->(sql, binds) { binds&.empty? ? sql : "#{sql} #{binds.inspect}" }
|
49
51
|
when :json
|
50
52
|
-> (sql, binds) { ::JSON.generate(sql: sql, binds: binds) }
|
51
53
|
when :hash
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_record-mod_sql_log_subscriber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryu39
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -42,30 +42,30 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -84,16 +84,16 @@ dependencies:
|
|
84
84
|
name: sqlite3
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: '0'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: '0'
|
97
97
|
description: An ActiveRecord::LogSubscriber which records only mod sql.
|
98
98
|
email:
|
99
99
|
- dev.ryu39@gmail.com
|
@@ -120,7 +120,7 @@ metadata:
|
|
120
120
|
homepage_uri: https://github.com/ryu39/active_record-mod_sql_log_subscriber
|
121
121
|
source_code_uri: https://github.com/ryu39/active_record-mod_sql_log_subscriber
|
122
122
|
changelog_uri: https://github.com/ryu39/active_record-mod_sql_log_subscriber
|
123
|
-
post_install_message:
|
123
|
+
post_install_message:
|
124
124
|
rdoc_options: []
|
125
125
|
require_paths:
|
126
126
|
- lib
|
@@ -135,9 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
|
-
|
139
|
-
|
140
|
-
signing_key:
|
138
|
+
rubygems_version: 3.2.3
|
139
|
+
signing_key:
|
141
140
|
specification_version: 4
|
142
141
|
summary: An ActiveRecord::LogSubscriber which records only mod sql.
|
143
142
|
test_files: []
|