rails-callback_log 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -0
- data/lib/rails-callback_log.rb +10 -3
- data/lib/rails_callback_log/version.rb +1 -1
- metadata +1 -2
- data/rails-callback_log-0.0.1.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b7821390ed7a47229737580cd6448e0480d654
|
4
|
+
data.tar.gz: 4d40de6817e02657dbbb207ae773b6b9693d222a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5eab678e68996cdea135dde6792b90e5a15c2af504f5f1659d602a3aca94b12f370e9f55b74c266c7dc3bfd348ac5d1c38c4d76171f544e65f34d29dd61946e
|
7
|
+
data.tar.gz: 3db5bff62da3cd1055247125a013d87956deebec44ddd52b92e2ff6ac98da70876bdd938010c6704cb83e0cff184cdc6ef2875c65f4fa5c4127b539002db7d99
|
data/README.md
CHANGED
@@ -11,6 +11,21 @@ gem "rails-callback_log", group: [:development, :test]
|
|
11
11
|
|
12
12
|
Do not use this gem in production because it adds significant overhead.
|
13
13
|
|
14
|
+
## Filtering Output
|
15
|
+
|
16
|
+
Rails has a lot of its own callbacks that you probably don't care about. If you
|
17
|
+
don't want to log them, enable filtering.
|
18
|
+
|
19
|
+
```
|
20
|
+
# Enable filtering
|
21
|
+
export RAILS_CALLBACK_LOG_FILTER="make it so"
|
22
|
+
|
23
|
+
# Disable filtering
|
24
|
+
unset RAILS_CALLBACK_LOG_FILTER
|
25
|
+
```
|
26
|
+
|
27
|
+
Filtering incurs a serious performance penalty, so it is off by default.
|
28
|
+
|
14
29
|
## License
|
15
30
|
|
16
31
|
The gem is available as open source under the terms of the [MIT
|
data/lib/rails-callback_log.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
require "active_support/callbacks"
|
2
2
|
require "rails_callback_log/version"
|
3
|
-
require 'benchmark'
|
4
3
|
|
5
4
|
module RailsCallbackLog
|
5
|
+
# Filtering is very expensive. It makes my test suite more than 50%
|
6
|
+
# slower. So, it's off by default.
|
7
|
+
FILTER = ENV["RAILS_CALLBACK_LOG_FILTER"].present?.freeze
|
8
|
+
|
6
9
|
class << self
|
7
10
|
def matches_filter?(str)
|
8
11
|
source_location_filters.any? { |f| str.start_with?(f) }
|
@@ -23,7 +26,8 @@ if ::Gem::Requirement.new("~> 4.2.0").satisfied_by?(::Rails.gem_version)
|
|
23
26
|
def make_lambda_with_log(filter)
|
24
27
|
original_lambda = make_lambda_without_log(filter)
|
25
28
|
lambda { |*args, &block|
|
26
|
-
if
|
29
|
+
if !::RailsCallbackLog::FILTER ||
|
30
|
+
caller.any? { |line| ::RailsCallbackLog.matches_filter?(line) }
|
27
31
|
::Rails.logger.debug(format("Callback: %s", filter))
|
28
32
|
end
|
29
33
|
original_lambda.call(*args, &block)
|
@@ -34,5 +38,8 @@ if ::Gem::Requirement.new("~> 4.2.0").satisfied_by?(::Rails.gem_version)
|
|
34
38
|
end
|
35
39
|
end
|
36
40
|
else
|
37
|
-
warn
|
41
|
+
warn(
|
42
|
+
"RailsCallbackLog does not support rails #{::Rails.gem_version} but " \
|
43
|
+
"contributions are welcome!"
|
44
|
+
)
|
38
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-callback_log
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jared Beck
|
@@ -83,7 +83,6 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- lib/rails-callback_log.rb
|
85
85
|
- lib/rails_callback_log/version.rb
|
86
|
-
- rails-callback_log-0.0.1.gem
|
87
86
|
- rails-callback_log.gemspec
|
88
87
|
homepage: https://github.com/jaredbeck/rails-callback_log
|
89
88
|
licenses:
|
Binary file
|