debug_logging 1.0.17 → 3.1.2

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: d234b40fc99de752fa25984cfd20bad70087a1147fccefaddf9e7b082fb9d1c7
4
- data.tar.gz: 291e57e9e9f9794da89ddf220744df3e1440902a86616aac10dc65779824ae73
3
+ metadata.gz: fb9df42efa08fe95b6c9270a4474132b2dbb55ed8d154d17c20dfde074781a8c
4
+ data.tar.gz: 459f277689fcb9b328b4c904730ae25bfe1c55fc87a5ab292157393f6b13c36b
5
5
  SHA512:
6
- metadata.gz: 3ed53e0d9b4d1205c66f0ec62ffe121c06f995db9f377c73da642dba8d68cade983fab6df802f20506959e28075874049c6ffd16882ee4589e1f1896a170a35c
7
- data.tar.gz: 74ff60f6e26a107a57c209e62205f3b2d5d8ecc36cd591d383f41bec46a2ced3c690389a920eb708e1654b0da44b78946558ef7820b47bfba51d8ee94d1fde61
6
+ metadata.gz: 5af7096cfbadcea5695cc19bdce85e4d6ac8eecf02139378cb2dc0d734d99011bc49ff239fe1d816ce9570a883b75b4f6e0772fdfbf7feda147e7890c56d415a
7
+ data.tar.gz: f471d3858ad20c1d3347b4ce328254c01572da54fd0e566ccbf6b15827996c561cf86c5fcb23f14ad127d5a9449b045c63281768c082b2375d754e566f3d4561
@@ -0,0 +1,107 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ require:
4
+ - 'rubocop-md'
5
+ - 'rubocop-performance'
6
+ - 'rubocop-rake'
7
+ - 'rubocop-rspec'
8
+
9
+ AllCops:
10
+ NewCops: enable
11
+
12
+ Layout/BeginEndAlignment: # (new in 0.91)
13
+ Enabled: true
14
+ Layout/EmptyLinesAroundAttributeAccessor: # (new in 0.83)
15
+ Enabled: true
16
+ Layout/SpaceAroundMethodCallOperator: # (new in 0.82)
17
+ Enabled: true
18
+ Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
19
+ Enabled: true
20
+ Lint/ConstantDefinitionInBlock: # (new in 0.91)
21
+ Enabled: true
22
+ Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
23
+ Enabled: true
24
+ Lint/DuplicateElsifCondition: # (new in 0.88)
25
+ Enabled: true
26
+ Lint/DuplicateRequire: # (new in 0.90)
27
+ Enabled: true
28
+ Lint/DuplicateRescueException: # (new in 0.89)
29
+ Enabled: true
30
+ Lint/EmptyConditionalBody: # (new in 0.89)
31
+ Enabled: true
32
+ Lint/EmptyFile: # (new in 0.90)
33
+ Enabled: true
34
+ Lint/FloatComparison: # (new in 0.89)
35
+ Enabled: true
36
+ Lint/IdentityComparison: # (new in 0.91)
37
+ Enabled: true
38
+ Lint/MissingSuper: # (new in 0.89)
39
+ Enabled: true
40
+ Lint/MixedRegexpCaptureTypes: # (new in 0.85)
41
+ Enabled: true
42
+ Lint/OutOfRangeRegexpRef: # (new in 0.89)
43
+ Enabled: true
44
+ Lint/RaiseException: # (new in 0.81)
45
+ Enabled: true
46
+ Lint/SelfAssignment: # (new in 0.89)
47
+ Enabled: true
48
+ Lint/StructNewOverride: # (new in 0.81)
49
+ Enabled: true
50
+ Lint/TopLevelReturnWithArgument: # (new in 0.89)
51
+ Enabled: true
52
+ Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
53
+ Enabled: true
54
+ Lint/UnreachableLoop: # (new in 0.89)
55
+ Enabled: true
56
+ Lint/UselessMethodDefinition: # (new in 0.90)
57
+ Enabled: true
58
+ Lint/UselessTimes: # (new in 0.91)
59
+ Enabled: true
60
+ Style/AccessorGrouping: # (new in 0.87)
61
+ Enabled: true
62
+ Style/BisectedAttrAccessor: # (new in 0.87)
63
+ Enabled: true
64
+ Style/CaseLikeIf: # (new in 0.88)
65
+ Enabled: true
66
+ Style/CombinableLoops: # (new in 0.90)
67
+ Enabled: true
68
+ Style/ExplicitBlockArgument: # (new in 0.89)
69
+ Enabled: true
70
+ Style/ExponentialNotation: # (new in 0.82)
71
+ Enabled: true
72
+ Style/GlobalStdStream: # (new in 0.89)
73
+ Enabled: true
74
+ Style/HashAsLastArrayItem: # (new in 0.88)
75
+ Enabled: true
76
+ Style/HashEachMethods: # (new in 0.80)
77
+ Enabled: true
78
+ Style/HashLikeCase: # (new in 0.88)
79
+ Enabled: true
80
+ Style/HashTransformKeys: # (new in 0.80)
81
+ Enabled: true
82
+ Style/HashTransformValues: # (new in 0.80)
83
+ Enabled: true
84
+ Style/KeywordParametersOrder: # (new in 0.90)
85
+ Enabled: true
86
+ Style/OptionalBooleanParameter: # (new in 0.89)
87
+ Enabled: true
88
+ Style/RedundantAssignment: # (new in 0.87)
89
+ Enabled: true
90
+ Style/RedundantFetchBlock: # (new in 0.86)
91
+ Enabled: true
92
+ Style/RedundantFileExtensionInRequire: # (new in 0.88)
93
+ Enabled: true
94
+ Style/RedundantRegexpCharacterClass: # (new in 0.85)
95
+ Enabled: true
96
+ Style/RedundantRegexpEscape: # (new in 0.85)
97
+ Enabled: true
98
+ Style/RedundantSelfAssignment: # (new in 0.90)
99
+ Enabled: true
100
+ Style/SingleArgumentDig: # (new in 0.89)
101
+ Enabled: true
102
+ Style/SlicingWithRange: # (new in 0.83)
103
+ Enabled: true
104
+ Style/SoleNestedConditional: # (new in 0.89)
105
+ Enabled: true
106
+ Style/StringConcatenation: # (new in 0.89)
107
+ Enabled: true
@@ -0,0 +1,167 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2020-12-10 04:35:55 UTC using RuboCop version 1.6.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 7
10
+ Lint/DuplicateMethods:
11
+ Exclude:
12
+ - 'README.md'
13
+
14
+ # Offense count: 6
15
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
16
+ Metrics/AbcSize:
17
+ Max: 96
18
+
19
+ # Offense count: 58
20
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
21
+ # IgnoredMethods: refine
22
+ Metrics/BlockLength:
23
+ Max: 851
24
+
25
+ # Offense count: 6
26
+ # Configuration parameters: CountBlocks.
27
+ Metrics/BlockNesting:
28
+ Max: 4
29
+
30
+ # Offense count: 4
31
+ # Configuration parameters: IgnoredMethods.
32
+ Metrics/CyclomaticComplexity:
33
+ Max: 24
34
+
35
+ # Offense count: 15
36
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
37
+ Metrics/MethodLength:
38
+ Max: 75
39
+
40
+ # Offense count: 2
41
+ # Configuration parameters: CountComments, CountAsOne.
42
+ Metrics/ModuleLength:
43
+ Max: 112
44
+
45
+ # Offense count: 5
46
+ # Configuration parameters: IgnoredMethods.
47
+ Metrics/PerceivedComplexity:
48
+ Max: 31
49
+
50
+ # Offense count: 3
51
+ # Configuration parameters: EnforcedStyleForLeadingUnderscores.
52
+ # SupportedStylesForLeadingUnderscores: disallowed, required, optional
53
+ Naming/MemoizedInstanceVariableName:
54
+ Exclude:
55
+ - 'lib/debug_logging/configuration.rb'
56
+
57
+ # Offense count: 60
58
+ # Configuration parameters: Prefixes.
59
+ # Prefixes: when, with, without
60
+ RSpec/ContextWording:
61
+ Exclude:
62
+ - 'spec/debug_logging/class_logger_spec.rb'
63
+ - 'spec/debug_logging/class_notifier_spec.rb'
64
+ - 'spec/debug_logging/configuration_spec.rb'
65
+ - 'spec/debug_logging/instance_logger_spec.rb'
66
+ - 'spec/debug_logging/instance_notifier_spec.rb'
67
+ - 'spec/debug_logging_spec.rb'
68
+
69
+ # Offense count: 46
70
+ # Configuration parameters: Max.
71
+ RSpec/ExampleLength:
72
+ Exclude:
73
+ - 'spec/debug_logging/class_logger_spec.rb'
74
+ - 'spec/debug_logging/class_notifier_spec.rb'
75
+ - 'spec/debug_logging/configuration_spec.rb'
76
+ - 'spec/debug_logging/instance_logger_spec.rb'
77
+ - 'spec/debug_logging/instance_notifier_spec.rb'
78
+ - 'spec/debug_logging/log_subscriber_spec.rb'
79
+ - 'spec/debug_logging_spec.rb'
80
+
81
+ # Offense count: 53
82
+ # Configuration parameters: AssignmentOnly.
83
+ RSpec/InstanceVariable:
84
+ Exclude:
85
+ - 'spec/debug_logging/class_notifier_spec.rb'
86
+ - 'spec/debug_logging/instance_notifier_spec.rb'
87
+ - 'spec/debug_logging/log_subscriber_spec.rb'
88
+
89
+ # Offense count: 4
90
+ RSpec/LeakyConstantDeclaration:
91
+ Exclude:
92
+ - 'spec/debug_logging/configuration_spec.rb'
93
+
94
+ # Offense count: 23
95
+ # Configuration parameters: .
96
+ # SupportedStyles: have_received, receive
97
+ RSpec/MessageSpies:
98
+ EnforcedStyle: receive
99
+
100
+ # Offense count: 80
101
+ RSpec/MultipleExpectations:
102
+ Max: 32
103
+
104
+ # Offense count: 1
105
+ # Configuration parameters: AllowSubject.
106
+ RSpec/MultipleMemoizedHelpers:
107
+ Max: 10
108
+
109
+ # Offense count: 27
110
+ RSpec/NestedGroups:
111
+ Max: 5
112
+
113
+ # Offense count: 1
114
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
115
+ RSpec/VerifiedDoubles:
116
+ Exclude:
117
+ - 'spec/support/shared_context.rb'
118
+
119
+ # Offense count: 1
120
+ # Configuration parameters: AllowedChars.
121
+ Style/AsciiComments:
122
+ Exclude:
123
+ - '**/*.md'
124
+ - '**/*.markdown'
125
+ - 'lib/debug_logging/configuration.rb'
126
+
127
+ # Offense count: 13
128
+ Style/Documentation:
129
+ Exclude:
130
+ - '**/*.md'
131
+ - '**/*.markdown'
132
+ - 'lib/debug_logging.rb'
133
+ - 'lib/debug_logging/argument_printer.rb'
134
+ - 'lib/debug_logging/class_logger.rb'
135
+ - 'lib/debug_logging/class_notifier.rb'
136
+ - 'lib/debug_logging/configuration.rb'
137
+ - 'lib/debug_logging/instance_logger.rb'
138
+ - 'lib/debug_logging/instance_logger_modulizer.rb'
139
+ - 'lib/debug_logging/instance_notifier.rb'
140
+ - 'lib/debug_logging/instance_notifier_modulizer.rb'
141
+ - 'lib/debug_logging/log_subscriber.rb'
142
+ - 'lib/simple_debug_logging.rb'
143
+
144
+ # Offense count: 2
145
+ # Cop supports --auto-correct.
146
+ # Configuration parameters: EnforcedStyle.
147
+ # SupportedStyles: empty, nil, both
148
+ Style/EmptyElse:
149
+ Exclude:
150
+ - 'lib/debug_logging/class_logger.rb'
151
+ - 'lib/debug_logging/class_notifier.rb'
152
+
153
+ # Offense count: 8
154
+ Style/IdenticalConditionalBranches:
155
+ Exclude:
156
+ - 'lib/debug_logging/class_logger.rb'
157
+ - 'lib/debug_logging/class_notifier.rb'
158
+ - 'lib/debug_logging/instance_logger_modulizer.rb'
159
+ - 'lib/debug_logging/instance_notifier_modulizer.rb'
160
+
161
+ # Offense count: 67
162
+ # Cop supports --auto-correct.
163
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
164
+ # URISchemes: http, https
165
+ # IgnoredPatterns: (?-mix:^\#)
166
+ Layout/LineLength:
167
+ Max: 207
@@ -9,6 +9,7 @@ before_script:
9
9
  - ./cc-test-reporter before-build
10
10
 
11
11
  script:
12
+ - bundle exec rubocop -DESP
12
13
  - bundle exec rspec
13
14
 
14
15
  after_script:
@@ -29,7 +30,7 @@ language: ruby
29
30
  sudo: false
30
31
 
31
32
  rvm:
32
- - ruby-2.3.7
33
- - ruby-2.4.4
34
- - ruby-2.5.1
35
- - jruby-9.1.9.0
33
+ - ruby-2.4.10
34
+ - ruby-2.5.8
35
+ - ruby-2.6.6
36
+ - ruby-2.7.2
data/Gemfile CHANGED
@@ -1,21 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  group :test do
6
- ruby_version = Gem::Version.new(RUBY_VERSION)
7
- if ruby_version >= Gem::Version.new('2.1')
8
- gem 'rubocop', '~> 0.59.0'
9
- gem 'rubocop-rspec', '~> 1.24.0'
10
- end
11
- if ruby_version >= Gem::Version.new('2.0')
12
- gem 'byebug', '~> 10', platform: :mri, require: false
13
- gem 'pry', '~> 0', platform: :mri, require: false
14
- gem 'pry-byebug', '~> 3', platform: :mri, require: false
15
- end
16
- # NOTE: Switching coveralls to simplecov causing many spec failures.
17
- # Something about coveralls bleeds into this gem, and this gem is
18
- # dependent on that tweaking behavior
19
8
  gem 'coveralls', '~> 0', require: false
20
9
  end
21
10
 
data/README.md CHANGED
@@ -2,11 +2,16 @@
2
2
 
3
3
  Unobtrusive, inheritable-overridable-configurable, drop-in debug logging, that won't leave a mess behind when it is time to remove it.
4
4
 
5
- NOTE: Septmeber 9, 2018 I discovered that some of the functionality of this gem is affected by the presence of the coveralls gem. All specs pass when it is loaded, and about 35% fail when it is not. I am going to figure out why this is. The failures mean that some logging features won't work as configured until I decouple this gem from coveralls.
5
+ ## What do I mean by "unobtrusive"?
6
+
7
+ **Ugly** debug logging is added inside the body of a method, so it runs when a method is called. This can create a mess of your git history, and can even introduce new bugs to your code.
8
+
9
+ **Unobtrusive** debug logging stays out of the method, changes no logic, can't break your code, and yet it still runs when your method is called, and tells you everything you wanted to know. It doesn't mess with the git history of the method at all!
6
10
 
7
11
  | Project | DebugLogging |
8
12
  |------------------------ | ----------------------- |
9
13
  | gem name | [debug_logging](https://rubygems.org/gems/debug_logging) |
14
+ | compatibility | Ruby 2.4, 2.5, 2.6, 2.7 |
10
15
  | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
11
16
  | download rank | [![Downloads Today](https://img.shields.io/gem/rd/debug_logging.svg)](https://github.com/pboling/debug_logging) |
12
17
  | version | [![Version](https://img.shields.io/gem/v/debug_logging.svg)](https://rubygems.org/gems/debug_logging) |
@@ -19,7 +24,7 @@ NOTE: Septmeber 9, 2018 I discovered that some of the functionality of this gem
19
24
  | documentation | [on RDoc.info][documentation] |
20
25
  | live chat | [![Join the chat at https://gitter.im/pboling/debug_logging](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/pboling/debug_logging?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
21
26
  | expert support | [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
22
- | Spread ~♡ⓛⓞⓥⓔ♡~ | [🌍 🌎 🌏](https://about.me/peter.boling), [🍚](https://www.crowdrise.com/helprefugeeswithhopefortomorrowliberia/fundraiser/peterboling), [➕](https://plus.google.com/+PeterBoling/posts), [👼](https://angel.co/peter-boling), [🐛](https://www.topcoder.com/members/pboling/), [:shipit:](http://coderwall.com/pboling), [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)](http://twitter.com/galtzo) |
27
+ | Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏](https://about.me/peter.boling), [👼](https://angel.co/peter-boling), [:shipit:](http://coderwall.com/pboling), [![Tweet Peter](https://img.shields.io/twitter/follow/galtzo.svg?style=social&label=Follow)](http://twitter.com/galtzo), [🌹](https://nationalprogressiveparty.org) |
23
28
 
24
29
  ### Gives you (all are optional):
25
30
 
@@ -30,28 +35,26 @@ NOTE: Septmeber 9, 2018 I discovered that some of the functionality of this gem
30
35
  * *single line config, per class/instance/method config*
31
36
  * *separate logger, if needed*
32
37
  * *log method calls, also when exit scope*
33
- * *Prevents heavy computation of strings with `logger.debug { 'log me' }` block format.*
38
+ * *Prevents heavy computation of strings with `logger.debug { 'log me' }` block format, since v1.0.12*
39
+ * *ActiveSupport::Notifications integration for instrumenting/logging events on class and instance methods, since v3.1*
40
+ * *Optional instance variable logging, sine v3.1*
34
41
  * **so many free ponies** 🎠🐴🎠🐴🎠🐴
35
42
 
36
43
  ## Next Level Magic
37
44
 
38
45
  Herein you will find:
39
46
 
40
- * Classes inheriting from Module.
41
- * Cats and dogs sleeping together.
42
- * Zero tolerance policy on monkey patching.
43
- * 100% clean, 0% obtrusive.
44
- * 100% tested.
45
- * 50% Ruby 2.0+ compatible.
46
- * 100% Ruby 2.1+ compatible, and therefore also compatible with JRuby 9000 and later.
47
- * 10g Monosodium glutamate.
47
+ * Classes inheriting from Module
48
+ * Zero tolerance policy on monkey patching
49
+ * 100% clean, 0% obtrusive
50
+ * 100% tested
51
+ * 100% Ruby 2.1+ compatible
52
+ - use version `gem "debug_logging", "~> 1.0"` for Ruby < 2.3
53
+ - use version `gem "debug_logging", "~> 2.0"` for Ruby 2.3
54
+ - use version `gem "debug_logging", "~> 3.0"` for Ruby 2.4+
48
55
 
49
56
  NOTE: The manner this is made to work for class methods is totally different than the way this is made to work for instance methods.
50
57
 
51
- NOTE: The instance method logging works on Ruby 2.0+
52
-
53
- NOTE: The class method logging works on Ruby 2.1+
54
-
55
58
  ## Installation
56
59
 
57
60
  Add this line to your application's Gemfile:
@@ -70,8 +73,6 @@ Or install it yourself as:
70
73
 
71
74
  ## Usage
72
75
 
73
- NOTE: Starting with version `1.0.12` this gem utilizes the `logger.debug { "block format" }` to avoid heavy debug processing when the log level threshold is set higher than the level of the statements produced as a result of the configuration of this gem.
74
-
75
76
  Crack open the specs for more complex usage examples than the ones below.
76
77
 
77
78
  ### Without Rails
@@ -85,7 +86,7 @@ Recommend creating `config/initializers/debug_logging.rb`, or adding to `config/
85
86
 
86
87
  ```ruby
87
88
  # Showing the defaults
88
- DebugLogging.configuration.logger = Logger.new(STDOUT) # you probably want to override to be the Rails.logger, and if so you can't set it in the initializer, as it needs to be set after Rails.logger is set.
89
+ DebugLogging.configuration.logger = Logger.new($stdout) # you probably want to override to be the Rails.logger, and if so you can't set it in the initializer, as it needs to be set after Rails.logger is set.
89
90
  DebugLogging.configuration.log_level = :debug # at what level do the messages created by this gem sent at?
90
91
  DebugLogging.configuration.multiple_last_hashes = false # pass every hash argument to last_hash_to_s_proc?
91
92
  DebugLogging.configuration.last_hash_to_s_proc = nil # e.g. ->(hash) { "keys: #{hash.keys}" }
@@ -93,10 +94,11 @@ DebugLogging.configuration.last_hash_max_length = 1_000
93
94
  DebugLogging.configuration.args_max_length = 1_000
94
95
  DebugLogging.configuration.instance_benchmarks = false
95
96
  DebugLogging.configuration.class_benchmarks = false
97
+ DebugLogging.configuration.active_support_notifications = false
96
98
  DebugLogging.configuration.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
97
99
  DebugLogging.configuration.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
98
100
  DebugLogging.configuration.add_invocation_id = true # identify a method call uniquely in a log, pass a proc for colorization, e.g. ->(colorized_string) { colorized_string.light_black }
99
- DebugLogging.configuration.ellipsis = " ✂️ …".freeze
101
+ DebugLogging.configuration.ellipsis = ' ✂️ …'.freeze
100
102
  DebugLogging.configuration.mark_scope_exit = true # Only has an effect if benchmarking is off, since benchmarking always marks the scope exit
101
103
  ```
102
104
 
@@ -104,7 +106,7 @@ If you prefer to use the block style:
104
106
 
105
107
  ```ruby
106
108
  DebugLogging.configure do |config|
107
- config.logger = Logger.new(STDOUT) # probably want to override to be the Rails.logger, and if so you can't set it in the initializer, as it needs to be set after Rails.logger is set.
109
+ config.logger = Logger.new($stdout) # probably want to override to be the Rails.logger, and if so you can't set it in the initializer, as it needs to be set after Rails.logger is set.
108
110
  config.log_level = :debug # at what level do the messages created by this gem sent at?
109
111
  config.multiple_last_hashes = false # pass every hash argument to last_hash_to_s_proc?
110
112
  config.last_hash_to_s_proc = nil # e.g. ->(hash) { "keys: #{hash.keys}" }
@@ -112,10 +114,11 @@ DebugLogging.configure do |config|
112
114
  config.args_max_length = 1_000
113
115
  config.instance_benchmarks = false
114
116
  config.class_benchmarks = false
117
+ config.active_support_notifications = false
115
118
  config.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
116
119
  config.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
117
120
  config.add_invocation_id = true # identify a method call uniquely in a log, pass a proc for colorization, e.g. ->(colorized_string) { colorized_string.light_black }
118
- config.ellipsis = " ✂️ …".freeze
121
+ config.ellipsis = ' ✂️ …'.freeze
119
122
  config.mark_scope_exit = true # Only has an effect if benchmarking is off, since benchmarking always marks the scope exit
120
123
  end
121
124
  ```
@@ -127,7 +130,7 @@ Just prepend `debug_` to any config value you want to override in a class.
127
130
  Just prepend `debug_` to any config value you want to override on an instance of a class.
128
131
 
129
132
  **All** of the above **config** is **inheritable** and **configurable** at the **per-method** level as well!
130
- Just send along a hash of the config options when you call `logged` or `include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop], config: { ellipsis = " ✂️ 2 much" })`. See the example class below, and the specs.
133
+ Just send along a hash of the config options when you call `logged` or `include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop], config: { ellipsis: " ✂️ 2 much" })`. See the example class below, and the specs.
131
134
 
132
135
  **NOTE ON** `Rails.logger` - It will probably be nil in your initializer, so setting the `config.logger` to `Rails.logger` there will result in setting it to `nil`, which means the default will end up being used: `Logger.new(STDOUT)`. Instead just config the logger in your application.rb, or anytime later, but *before your classes get loaded* and start inheriting the config:
133
136
 
@@ -135,46 +138,186 @@ Just send along a hash of the config options when you call `logged` or `include
135
138
  DebugLogging.configuration.logger = Rails.logger
136
139
  ```
137
140
 
138
- Every time a method is called, get logs, optionally with arguments, a benchmarck, and a unique invocation identifier:
141
+ Every time a method is called, you can now get logs, optionally with arguments, a benchmark, and a unique invocation identifier:
139
142
 
140
143
  ```ruby
141
144
  class Car
142
-
143
- # adds the helper methods to the class, all are prefixed with debug_*,
144
- # except for the logged class method, which comes from extending DebugLogging::ClassLogger
145
+ # Adds the helper methods to the class.
146
+ # All helpers prefixed with debug_*,
147
+ # except for the *logged* decorator, which comes from extending DebugLogging::ClassLogger
145
148
  extend DebugLogging
146
149
 
147
150
  # per class configuration overrides!
148
151
  self.debug_class_benchmarks = true
149
152
  self.debug_instance_benchmarks = true
150
153
 
151
- # For instance methods:
152
- # Option 1: specify the exact method(s) to add logging to
153
- include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop])
154
-
155
- # Provides the `logged` method decorator
154
+ # For class methods
155
+ # Provides the versatile `logged` method decorator / macro
156
+ # For instance methods
157
+ # Provides the versatile `i_logged` method decorator / macro
156
158
  extend DebugLogging::ClassLogger
157
159
 
158
- logged def make; new; end
159
- def design(*args); new; end
160
- def safety(*args); new; end
161
- def dealer_options(*args); new; end
160
+ # == BEGIN CLASS METHODS ==
161
+ # For class methods:
162
+ # Option 1: Use *logged* as a method decorator
163
+ logged def self.make
164
+ new
165
+ end
166
+ def self.design(*_args)
167
+ new
168
+ end
169
+
170
+ def self.safety(*_args)
171
+ new
172
+ end
173
+
174
+ def self.dealer_options(*_args)
175
+ new
176
+ end
177
+
178
+ # Option 2: Use *logged* as a macro
162
179
  logged :design, :safety
163
- # override options for any instance method(s), by passing a hash as the last argument
164
- logged :dealer_options, { multiple_last_hashes: true }
180
+ # Override configuration options for any class method(s), by passing a hash as the last argument
181
+ # In the last hash any non-Configuration keys will be data that gets logged,
182
+ # and also made available to last_hash_to_s_proc
183
+ logged :dealer_options, {
184
+ something: 'here', # <= will be logged, and available to last_hash_to_s_proc
185
+ multiple_last_hashes: true # <= Overrides config
186
+ }
187
+ def self.will_not_be_logged
188
+ false
189
+ end
190
+ # == END CLASS METHODS ==
191
+
192
+ # == BEGIN INSTANCE METHODS ==
193
+ # For instance methods:
194
+ # Option 1: specify the exact method(s) to add logging to
195
+ include DebugLogging::InstanceLogger.new(i_methods: %i[drive stop])
165
196
 
166
- def drive(speed); speed; end
167
- def stop(**opts); 0; end
197
+ def drive(speed)
198
+ speed
199
+ end
200
+
201
+ def stop(**_opts)
202
+ 0
203
+ end
168
204
 
169
205
  # For instance methods:
170
206
  # Option 2: add logging to all instance methods defined above (but *not* defined below)
171
- include DebugLogging::InstanceLogger.new(i_methods: self.instance_methods(false))
207
+ include DebugLogging::InstanceLogger.new(i_methods: instance_methods(false))
208
+
209
+ def faster(**_opts)
210
+ 0
211
+ end
212
+
213
+ # Override configuration options for any instance method(s), by passing a hash as the last argument
214
+ # In the last hash any non-Configuration keys will be data that gets logged,
215
+ # and also made available to last_hash_to_s_proc
216
+ include DebugLogging::InstanceLogger.new(i_methods: [:faster], config: { add_invocation_id: false })
217
+
218
+ def will_not_be_logged
219
+ false
220
+ end
221
+ # == END INSTANCE METHODS ==
222
+ end
223
+ ```
172
224
 
173
- # override options for any instance method(s)
174
- include DebugLogging::InstanceLogger.new(i_methods: [:stop], config: { multiple_last_hashes: true })
225
+ ### ActiveSupport::Notifications integration
175
226
 
176
- def will_not_be_logged; false; end
227
+ To use `ActiveSupport::Notifications` integration, enable `active_support_notifications` in the config, either single line or block style:
177
228
 
229
+ ```ruby
230
+ DebugLogging.configuration.active_support_notifications = true
231
+ ```
232
+
233
+ or
234
+
235
+ ```ruby
236
+ DebugLogging.configure do |config|
237
+ config.active_support_notifications = true
238
+ end
239
+ ```
240
+
241
+ Every time a method is called, class and instance method events are instrumented, consumed and logged:
242
+
243
+ ```ruby
244
+ class Car
245
+ # Adds the helper methods to the class.
246
+ # All helpers prefixed with debug_*,
247
+ # except for the *notifies* decorator, which comes from extending DebugLogging::ClassNotifier
248
+ extend DebugLogging
249
+
250
+ # For instance methods:
251
+ # Option 1: specify the exact method(s) to add instrumentation to
252
+ # NOTE: You can capture instance variable values as part of the event payload
253
+ include DebugLogging::InstanceNotifier.new(i_methods: [:drive,
254
+ :stop,
255
+ [:turn, { instance_variables: %i[direction angle] }]])
256
+
257
+ # For class methods
258
+ # Provides the versatile `notifies` method decorator / macro
259
+ # For instance methods
260
+ # Provides the versatile `i_notifies` method decorator / macro
261
+ extend DebugLogging::ClassNotifier
262
+
263
+ # == BEGIN CLASS METHODS ==
264
+ # For class methods:
265
+ # Option 1: Use *notifies* as a method decorator
266
+ notifies def self.make
267
+ new
268
+ end
269
+ def self.design(*_args)
270
+ new
271
+ end
272
+
273
+ def self.safety(*_args)
274
+ new
275
+ end
276
+
277
+ def self.dealer_options(*_args)
278
+ new
279
+ end
280
+
281
+ # Option 2: Use *logged* as a macro
282
+ notifies :design, :safety
283
+ # Override configuration options for any class method(s), by passing a hash as the last argument
284
+ # In the last hash any non-Configuration keys will be data that gets added to the event payload,
285
+ # and also made available to last_hash_to_s_proc
286
+ notifies :dealer_options, {
287
+ something: 'here', # <= will be added to the event payload, and be available to last_hash_to_s_proc
288
+ add_invocation_id: false # <= Overrides config
289
+ }
290
+ def self.will_not_be_notified
291
+ false
292
+ end
293
+ # == END CLASS METHODS ==
294
+
295
+ # == BEGIN INSTANCE METHODS ==
296
+ def drive(speed)
297
+ speed
298
+ end
299
+
300
+ def stop(**_opts)
301
+ 0
302
+ end
303
+
304
+ # For instance methods:
305
+ # Option 2: add instrumentation to all instance methods defined above (but *not* defined below)
306
+ include DebugLogging::InstanceNotifier.new(i_methods: instance_methods(false))
307
+
308
+ def faster(**_opts)
309
+ 0
310
+ end
311
+
312
+ # Override options for any instance method(s), by passing a hash as the last argument
313
+ # In the last hash any non-Configuration keys will be data that gets added to the event payload,
314
+ # and also made available to last_hash_to_s_proc
315
+ include DebugLogging::InstanceNotifier.new(i_methods: [:faster], config: { add_invocation_id: false })
316
+
317
+ def will_not_be_notified
318
+ false
319
+ end
320
+ # == END INSTANCE METHODS ==
178
321
  end
179
322
  ```
180
323
 
@@ -210,14 +353,14 @@ dependency on this gem using the [Pessimistic Version Constraint](http://docs.ru
210
353
  For example:
211
354
 
212
355
  ```ruby
213
- spec.add_dependency 'debug_logging', '~> 1.0'
356
+ spec.add_dependency 'debug_logging', '~> 3.1'
214
357
  ```
215
358
 
216
359
  ## License [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
217
360
 
218
361
  MIT License
219
362
 
220
- Copyright (c) 2017 - 2018 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
363
+ Copyright (c) 2017 - 2020 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
221
364
 
222
365
  Permission is hereby granted, free of charge, to any person obtaining
223
366
  a copy of this software and associated documentation files (the