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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9a8af36a5c5fc9468e210d7e75aa24370dea5e4
4
- data.tar.gz: 3302100a2b3a0a6a11fe3b801da5809f22c3e40a
3
+ metadata.gz: 55b7821390ed7a47229737580cd6448e0480d654
4
+ data.tar.gz: 4d40de6817e02657dbbb207ae773b6b9693d222a
5
5
  SHA512:
6
- metadata.gz: fb26d8950b7153871b18ba675f2e6cb60fb07c9d006da66a05a2e0a31395aa36f2e64fde91bf0ba6a9a5faffb8747aa301e53e3f98c97ad7195ed991c4e93e9e
7
- data.tar.gz: 8e8613bf6d54a067107039aaa6b267aaff1c6bfc4885d5f0156cc512ac8d6cce388b6397db51f6f78b210ed9cace42efc24c2b4f77df1010dab339b30d04832d
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
@@ -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 caller.any? { |line| ::RailsCallbackLog.matches_filter?(line) }
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 "RailsCallbackLog does not support rails version: #{::Rails.gem_version}"
41
+ warn(
42
+ "RailsCallbackLog does not support rails #{::Rails.gem_version} but " \
43
+ "contributions are welcome!"
44
+ )
38
45
  end
@@ -1,5 +1,5 @@
1
1
  module RailsCallbackLog
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
 
4
4
  def self.gem_version
5
5
  ::Gem::Version.new(VERSION)
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.2
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