debug_logging 1.0.16 → 3.1.1

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
- SHA1:
3
- metadata.gz: 7b60bc223b54c444ecb4a5f2bf18dfd5b5fecf6d
4
- data.tar.gz: 7bfa44e68f005b8228eabf0d9acaa0e7c7854119
2
+ SHA256:
3
+ metadata.gz: a39fc11d3fc815e37db037fd9ce8b08e74e5d98e7612a50f191231ba3ce95231
4
+ data.tar.gz: 99ef91cf9302dfc413ebba74435464933524cfa1a2e70f9623b97ff64c849729
5
5
  SHA512:
6
- metadata.gz: 551c2ca98ea8677870a35119cc4660078567e40a1846c42efd4d83dc691dc0049c8e4cbca0fc836b8ef922f432fcb6d8365fd15e898c9b8ee61a4a8f3954f663
7
- data.tar.gz: 8e7879539497cc61d036da4c6df92ac5e10ff88d049d38773b7ec3fec7e46eaf728ebbb077ac8ba8be7d9534f65cd96882ebffb38f7f60ba7c1e5be8fad4953c
6
+ metadata.gz: 22ec37827bdf34889a023d235315ee4ca85642cdc070a22751be328f58c8f4b8b22c952da52c2d6900f3bc44431d8d0dd5800483419532f3fd5a5aca9227d529
7
+ data.tar.gz: 5b5456b83dfff252840e31ea81af17e5d3b50bdc025e090d55731fcd16353d41352b2304ba53818c791f9ec3970a447e4b01624fd269d6663951a444a876ac6d
@@ -0,0 +1,99 @@
1
+ AllCops:
2
+ NewCops: enable
3
+
4
+ Layout/BeginEndAlignment: # (new in 0.91)
5
+ Enabled: true
6
+ Layout/EmptyLinesAroundAttributeAccessor: # (new in 0.83)
7
+ Enabled: true
8
+ Layout/SpaceAroundMethodCallOperator: # (new in 0.82)
9
+ Enabled: true
10
+ Lint/BinaryOperatorWithIdenticalOperands: # (new in 0.89)
11
+ Enabled: true
12
+ Lint/ConstantDefinitionInBlock: # (new in 0.91)
13
+ Enabled: true
14
+ Lint/DeprecatedOpenSSLConstant: # (new in 0.84)
15
+ Enabled: true
16
+ Lint/DuplicateElsifCondition: # (new in 0.88)
17
+ Enabled: true
18
+ Lint/DuplicateRequire: # (new in 0.90)
19
+ Enabled: true
20
+ Lint/DuplicateRescueException: # (new in 0.89)
21
+ Enabled: true
22
+ Lint/EmptyConditionalBody: # (new in 0.89)
23
+ Enabled: true
24
+ Lint/EmptyFile: # (new in 0.90)
25
+ Enabled: true
26
+ Lint/FloatComparison: # (new in 0.89)
27
+ Enabled: true
28
+ Lint/IdentityComparison: # (new in 0.91)
29
+ Enabled: true
30
+ Lint/MissingSuper: # (new in 0.89)
31
+ Enabled: true
32
+ Lint/MixedRegexpCaptureTypes: # (new in 0.85)
33
+ Enabled: true
34
+ Lint/OutOfRangeRegexpRef: # (new in 0.89)
35
+ Enabled: true
36
+ Lint/RaiseException: # (new in 0.81)
37
+ Enabled: true
38
+ Lint/SelfAssignment: # (new in 0.89)
39
+ Enabled: true
40
+ Lint/StructNewOverride: # (new in 0.81)
41
+ Enabled: true
42
+ Lint/TopLevelReturnWithArgument: # (new in 0.89)
43
+ Enabled: true
44
+ Lint/TrailingCommaInAttributeDeclaration: # (new in 0.90)
45
+ Enabled: true
46
+ Lint/UnreachableLoop: # (new in 0.89)
47
+ Enabled: true
48
+ Lint/UselessMethodDefinition: # (new in 0.90)
49
+ Enabled: true
50
+ Lint/UselessTimes: # (new in 0.91)
51
+ Enabled: true
52
+ Style/AccessorGrouping: # (new in 0.87)
53
+ Enabled: true
54
+ Style/BisectedAttrAccessor: # (new in 0.87)
55
+ Enabled: true
56
+ Style/CaseLikeIf: # (new in 0.88)
57
+ Enabled: true
58
+ Style/CombinableLoops: # (new in 0.90)
59
+ Enabled: true
60
+ Style/ExplicitBlockArgument: # (new in 0.89)
61
+ Enabled: true
62
+ Style/ExponentialNotation: # (new in 0.82)
63
+ Enabled: true
64
+ Style/GlobalStdStream: # (new in 0.89)
65
+ Enabled: true
66
+ Style/HashAsLastArrayItem: # (new in 0.88)
67
+ Enabled: true
68
+ Style/HashEachMethods: # (new in 0.80)
69
+ Enabled: true
70
+ Style/HashLikeCase: # (new in 0.88)
71
+ Enabled: true
72
+ Style/HashTransformKeys: # (new in 0.80)
73
+ Enabled: true
74
+ Style/HashTransformValues: # (new in 0.80)
75
+ Enabled: true
76
+ Style/KeywordParametersOrder: # (new in 0.90)
77
+ Enabled: true
78
+ Style/OptionalBooleanParameter: # (new in 0.89)
79
+ Enabled: true
80
+ Style/RedundantAssignment: # (new in 0.87)
81
+ Enabled: true
82
+ Style/RedundantFetchBlock: # (new in 0.86)
83
+ Enabled: true
84
+ Style/RedundantFileExtensionInRequire: # (new in 0.88)
85
+ Enabled: true
86
+ Style/RedundantRegexpCharacterClass: # (new in 0.85)
87
+ Enabled: true
88
+ Style/RedundantRegexpEscape: # (new in 0.85)
89
+ Enabled: true
90
+ Style/RedundantSelfAssignment: # (new in 0.90)
91
+ Enabled: true
92
+ Style/SingleArgumentDig: # (new in 0.89)
93
+ Enabled: true
94
+ Style/SlicingWithRange: # (new in 0.83)
95
+ Enabled: true
96
+ Style/SoleNestedConditional: # (new in 0.89)
97
+ Enabled: true
98
+ Style/StringConcatenation: # (new in 0.89)
99
+ Enabled: true
@@ -0,0 +1,133 @@
1
+ inherit_from: .rubocop.yml
2
+
3
+ # This configuration was generated by
4
+ # `rubocop --auto-gen-config`
5
+ # on 2020-10-06 07:34:51 UTC using RuboCop version 0.92.0.
6
+ # The point is for the user to remove these configuration records
7
+ # one by one as the offenses are removed from the code base.
8
+ # Note that changes in the inspected code, or installation of new
9
+ # versions of RuboCop, may require this file to be generated again.
10
+
11
+ # Offense count: 1
12
+ # Configuration parameters: Include.
13
+ # Include: **/*.gemspec
14
+ Gemspec/RequiredRubyVersion:
15
+ Exclude:
16
+ - 'debug_logging.gemspec'
17
+
18
+ # Offense count: 1
19
+ # Cop supports --auto-correct.
20
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
21
+ # SupportedStyles: space, no_space
22
+ # SupportedStylesForEmptyBraces: space, no_space
23
+ Layout/SpaceInsideBlockBraces:
24
+ Exclude:
25
+ - 'lib/debug_logging/argument_printer.rb'
26
+
27
+ # Offense count: 5
28
+ # Configuration parameters: IgnoredMethods.
29
+ Metrics/AbcSize:
30
+ Max: 97
31
+
32
+ # Offense count: 38
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
34
+ # ExcludedMethods: refine
35
+ Metrics/BlockLength:
36
+ Max: 810
37
+
38
+ # Offense count: 6
39
+ # Configuration parameters: CountBlocks.
40
+ Metrics/BlockNesting:
41
+ Max: 4
42
+
43
+ # Offense count: 1
44
+ # Configuration parameters: CountComments, CountAsOne.
45
+ Metrics/ClassLength:
46
+ Max: 101
47
+
48
+ # Offense count: 4
49
+ # Configuration parameters: IgnoredMethods.
50
+ Metrics/CyclomaticComplexity:
51
+ Max: 22
52
+
53
+ # Offense count: 11
54
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
55
+ Metrics/MethodLength:
56
+ Max: 50
57
+
58
+ # Offense count: 1
59
+ # Configuration parameters: CountComments, CountAsOne.
60
+ Metrics/ModuleLength:
61
+ Max: 112
62
+
63
+ # Offense count: 4
64
+ # Configuration parameters: IgnoredMethods.
65
+ Metrics/PerceivedComplexity:
66
+ Max: 26
67
+
68
+ # Offense count: 1
69
+ # Configuration parameters: AllowedChars.
70
+ Style/AsciiComments:
71
+ Exclude:
72
+ - 'lib/debug_logging/configuration.rb'
73
+
74
+ # Offense count: 1
75
+ # Cop supports --auto-correct.
76
+ # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
77
+ # SupportedStyles: assign_to_condition, assign_inside_condition
78
+ Style/ConditionalAssignment:
79
+ Exclude:
80
+ - 'lib/debug_logging/argument_printer.rb'
81
+
82
+ # Offense count: 9
83
+ Style/Documentation:
84
+ Exclude:
85
+ - 'spec/**/*'
86
+ - 'test/**/*'
87
+ - 'lib/debug_logging.rb'
88
+ - 'lib/debug_logging/argument_printer.rb'
89
+ - 'lib/debug_logging/class_logger.rb'
90
+ - 'lib/debug_logging/class_notifier.rb'
91
+ - 'lib/debug_logging/configuration.rb'
92
+ - 'lib/debug_logging/instance_logger.rb'
93
+ - 'lib/debug_logging/instance_logger_modulizer.rb'
94
+ - 'lib/debug_logging/instance_notifier.rb'
95
+ - 'lib/debug_logging/instance_notifier_modulizer.rb'
96
+ - 'lib/debug_logging/log_subscriber.rb'
97
+ - 'lib/simple_debug_logging.rb'
98
+
99
+ # Offense count: 1
100
+ # Cop supports --auto-correct.
101
+ # Configuration parameters: EnforcedStyle.
102
+ # SupportedStyles: empty, nil, both
103
+ Style/EmptyElse:
104
+ Exclude:
105
+ - 'lib/debug_logging/class_logger.rb'
106
+ - 'lib/debug_logging/class_notifier.rb'
107
+
108
+ # Offense count: 2
109
+ # Configuration parameters: EnforcedStyle.
110
+ # SupportedStyles: annotated, template, unannotated
111
+ Style/FormatStringToken:
112
+ Exclude:
113
+ - 'lib/debug_logging/argument_printer.rb'
114
+
115
+ # Offense count: 4
116
+ Style/IdenticalConditionalBranches:
117
+ Exclude:
118
+ - 'lib/debug_logging/class_logger.rb'
119
+ - 'lib/debug_logging/class_notifier.rb'
120
+ - 'lib/debug_logging/instance_logger_modulizer.rb'
121
+ - 'lib/debug_logging/instance_notifier_modulizer.rb'
122
+
123
+ # Offense count: 1
124
+ Style/MultilineBlockChain:
125
+ Exclude:
126
+ - 'lib/debug_logging/argument_printer.rb'
127
+
128
+ # Offense count: 95
129
+ # Cop supports --auto-correct.
130
+ # Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
131
+ # URISchemes: http, https
132
+ Layout/LineLength:
133
+ Max: 223
@@ -1,7 +1,36 @@
1
- sudo: false
1
+ env:
2
+ global:
3
+ - JRUBY_OPTS="-Xcli.debug=true --debug"
4
+ - CC_TEST_REPORTER_ID=b78cb927bf15a7aee5aacd4486215628550f784e77d137a2da8c96c417a068ff
5
+
6
+ before_script:
7
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
8
+ - chmod +x ./cc-test-reporter
9
+ - ./cc-test-reporter before-build
10
+
11
+ script:
12
+ - bundle exec rubocop -DESP --config ./.rubocop_todo.yml
13
+ - bundle exec rspec
14
+
15
+ after_script:
16
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
17
+
18
+ before_install:
19
+ - gem update --system
20
+ - gem install bundler
21
+
22
+ install:
23
+ - bundle install
24
+
25
+ bundler_args: --no-deployment --jobs 3 --retry 3
26
+
27
+ cache: bundler
28
+
2
29
  language: ruby
30
+ sudo: false
31
+
3
32
  rvm:
4
- - ruby-2.3.4
5
- - ruby-2.4.2
6
- - jruby-9.1.9.0
7
- before_install: gem install bundler -v 1.15.4
33
+ - ruby-2.4.10
34
+ - ruby-2.5.8
35
+ - ruby-2.6.6
36
+ - ruby-2.7.1
data/Gemfile CHANGED
@@ -1,6 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ group :test do
8
+ gem 'coveralls', '~> 0', require: false
9
+ end
10
+
3
11
  # Specify your gem's dependencies in debug_logging.gemspec
4
12
  gemspec
5
-
6
- gem 'byebug', '~> 9.0', platform: :mri
data/README.md CHANGED
@@ -2,7 +2,32 @@
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
+ ## 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!
10
+
11
+ | Project | DebugLogging |
12
+ |------------------------ | ----------------------- |
13
+ | gem name | [debug_logging](https://rubygems.org/gems/debug_logging) |
14
+ | compatibility | Ruby 2.4, 2.5, 2.6, 2.7 |
15
+ | license | [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) |
16
+ | download rank | [![Downloads Today](https://img.shields.io/gem/rd/debug_logging.svg)](https://github.com/pboling/debug_logging) |
17
+ | version | [![Version](https://img.shields.io/gem/v/debug_logging.svg)](https://rubygems.org/gems/debug_logging) |
18
+ | dependencies | [![Depfu](https://badges.depfu.com/badges/d1a4cf43255916521fef1e3685c61faa/count.svg)](https://depfu.com/github/pboling/debug_logging?project_id=2675) |
19
+ | continuous integration | [![Build Status](https://travis-ci.org/pboling/debug_logging.svg?branch=master)](https://travis-ci.org/pboling/debug_logging) |
20
+ | test coverage | [![Test Coverage](https://api.codeclimate.com/v1/badges/1f36d7019c3b81cae1a2/test_coverage)](https://codeclimate.com/github/pboling/debug_logging/test_coverage) |
21
+ | maintainability | [![Maintainability](https://api.codeclimate.com/v1/badges/1f36d7019c3b81cae1a2/maintainability)](https://codeclimate.com/github/pboling/debug_logging/maintainability) |
22
+ | code triage | [![Open Source Helpers](https://www.codetriage.com/pboling/debug_logging/badges/users.svg)](https://www.codetriage.com/pboling/debug_logging) |
23
+ | homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
24
+ | documentation | [on RDoc.info][documentation] |
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) |
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) |
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) |
28
+
5
29
  ### Gives you (all are optional):
30
+
6
31
  * *benchmarking*
7
32
  * *colorization by class/method*
8
33
  * *robust argument printer with customizable ellipsis*
@@ -10,45 +35,26 @@ Unobtrusive, inheritable-overridable-configurable, drop-in debug logging, that w
10
35
  * *single line config, per class/instance/method config*
11
36
  * *separate logger, if needed*
12
37
  * *log method calls, also when exit scope*
13
- * *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*
14
41
  * **so many free ponies** 🎠🐴🎠🐴🎠🐴
15
42
 
16
- | Project | DebugLogging |
17
- |------------------------ | ----------------- |
18
- | gem name | debug_logging |
19
- | license | [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) |
20
- | 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) |
21
- | download rank | [![Total Downloads](https://img.shields.io/gem/rt/debug_logging.svg)](https://rubygems.org/gems/debug_logging) |
22
- | version | [![Gem Version](https://badge.fury.io/rb/debug_logging.svg)](http://badge.fury.io/rb/debug_logging) |
23
- | dependencies | [![Dependency Status](https://gemnasium.com/pboling/debug_logging.svg)](https://gemnasium.com/pboling/debug_logging) |
24
- | code quality | [![Code Climate](https://codeclimate.com/github/pboling/debug_logging.svg)](https://codeclimate.com/github/pboling/debug_logging) |
25
- | continuous integration | [![Build Status](https://secure.travis-ci.org/pboling/debug_logging.svg?branch=master)](https://travis-ci.org/pboling/debug_logging) |
26
- | test coverage | [![Coverage Status](https://coveralls.io/repos/pboling/debug_logging/badge.svg)](https://coveralls.io/r/pboling/debug_logging) |
27
- | homepage | [https://github.com/pboling/debug_logging][homepage] |
28
- | documentation | [http://rdoc.info/github/pboling/debug_logging/frames][documentation] |
29
- | 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) |
30
- | Spread ~♡ⓛⓞⓥⓔ♡~ | [on AngelList][angellist], [on Coderwall][coderwall] |
31
-
32
43
  ## Next Level Magic
33
44
 
34
-
35
45
  Herein you will find:
36
46
 
37
- * Classes inheriting from Module.
38
- * Cats and dogs sleeping together.
39
- * Zero tolerance policy on monkey patching.
40
- * 100% clean, 0% obtrusive.
41
- * 100% tested.
42
- * 50% Ruby 2.0+ compatible.
43
- * 100% Ruby 2.1+ compatible, and therefore also compatible with JRuby 9000 and later.
44
- * 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+
45
55
 
46
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.
47
57
 
48
- NOTE: The instance method logging works on Ruby 2.0+
49
-
50
- NOTE: The class method logging works on Ruby 2.1+
51
-
52
58
  ## Installation
53
59
 
54
60
  Add this line to your application's Gemfile:
@@ -67,18 +73,16 @@ Or install it yourself as:
67
73
 
68
74
  ## Usage
69
75
 
70
- 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.
71
-
72
76
  Crack open the specs for more complex usage examples than the ones below.
73
77
 
74
78
  ### Without Rails
75
79
 
76
80
  It just works. ;)
77
- Configuration can go anywhere you want. It will look like the Rails config though; see below.
81
+ Configuration can go anywhere you want. Configuration is the same regardless; see below.
78
82
 
79
83
  ### With Rails
80
84
 
81
- Recommend creating `config/initializers/debug_logging.rb` with:
85
+ Recommend creating `config/initializers/debug_logging.rb`, or adding to `config/application.rb` with:
82
86
 
83
87
  ```ruby
84
88
  # Showing the defaults
@@ -90,6 +94,7 @@ DebugLogging.configuration.last_hash_max_length = 1_000
90
94
  DebugLogging.configuration.args_max_length = 1_000
91
95
  DebugLogging.configuration.instance_benchmarks = false
92
96
  DebugLogging.configuration.class_benchmarks = false
97
+ DebugLogging.configuration.active_support_notifications = false
93
98
  DebugLogging.configuration.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
94
99
  DebugLogging.configuration.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
95
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 }
@@ -109,6 +114,7 @@ DebugLogging.configure do |config|
109
114
  config.args_max_length = 1_000
110
115
  config.instance_benchmarks = false
111
116
  config.class_benchmarks = false
117
+ config.active_support_notifications = false
112
118
  config.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
113
119
  config.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
114
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 }
@@ -124,7 +130,7 @@ Just prepend `debug_` to any config value you want to override in a class.
124
130
  Just prepend `debug_` to any config value you want to override on an instance of a class.
125
131
 
126
132
  **All** of the above **config** is **inheritable** and **configurable** at the **per-method** level as well!
127
- 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.
128
134
 
129
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:
130
136
 
@@ -132,33 +138,49 @@ Just send along a hash of the config options when you call `logged` or `include
132
138
  DebugLogging.configuration.logger = Rails.logger
133
139
  ```
134
140
 
135
- 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:
136
142
 
137
143
  ```ruby
138
144
  class Car
139
-
140
- # adds the helper methods to the class, all are prefixed with debug_*,
141
- # 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
142
148
  extend DebugLogging
143
149
 
144
150
  # per class configuration overrides!
145
151
  self.debug_class_benchmarks = true
146
152
  self.debug_instance_benchmarks = true
147
153
 
148
- # For instance methods:
149
- # Option 1: specify the exact method(s) to add logging to
150
- include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop])
151
-
152
- # 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
153
158
  extend DebugLogging::ClassLogger
154
159
 
155
- logged def make; new; end
156
- def design(*args); new; end
157
- def safety(*args); new; end
158
- 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; new; end
164
+ def self.design(*args); new; end
165
+ def self.safety(*args); new; end
166
+ def self.dealer_options(*args); new; end
167
+
168
+ # Option 2: Use *logged* as a macro
159
169
  logged :design, :safety
160
- # override options for any instance method(s), by passing a hash as the last argument
161
- logged :dealer_options, { multiple_last_hashes: true }
170
+ # Override configuration options for any class method(s), by passing a hash as the last argument
171
+ # In the last hash any non-Configuration keys will be data that gets logged,
172
+ # and also made available to last_hash_to_s_proc
173
+ logged :dealer_options, {
174
+ something: 'here', # <= will be logged, and available to last_hash_to_s_proc
175
+ multiple_last_hashes: true # <= Overrides config
176
+ }
177
+ def self.will_not_be_logged; false; end
178
+ # == END CLASS METHODS ==
179
+
180
+ # == BEGIN INSTANCE METHODS ==
181
+ # For instance methods:
182
+ # Option 1: specify the exact method(s) to add logging to
183
+ include DebugLogging::InstanceLogger.new(i_methods: [:drive, :stop])
162
184
 
163
185
  def drive(speed); speed; end
164
186
  def stop(**opts); 0; end
@@ -167,11 +189,93 @@ class Car
167
189
  # Option 2: add logging to all instance methods defined above (but *not* defined below)
168
190
  include DebugLogging::InstanceLogger.new(i_methods: self.instance_methods(false))
169
191
 
170
- # override options for any instance method(s)
171
- include DebugLogging::InstanceLogger.new(i_methods: [:stop], config: { multiple_last_hashes: true })
192
+ def faster(**opts); 0; end
193
+
194
+ # Override configuration options for any instance method(s), by passing a hash as the last argument
195
+ # In the last hash any non-Configuration keys will be data that gets logged,
196
+ # and also made available to last_hash_to_s_proc
197
+ include DebugLogging::InstanceLogger.new(i_methods: [:faster], config: { add_invocation_id: false })
172
198
 
173
199
  def will_not_be_logged; false; end
200
+ # == END INSTANCE METHODS ==
201
+ end
202
+ ```
203
+
204
+ ### ActiveSupport::Notifications integration
205
+
206
+ To use `ActiveSupport::Notifications` integration, enable `active_support_notifications` in the config, either single line or block style:
207
+
208
+ ```ruby
209
+ DebugLogging.configuration.active_support_notifications = true
210
+ ```
211
+
212
+ or
213
+
214
+ ```ruby
215
+ DebugLogging.configure do |config|
216
+ config.active_support_notifications = true
217
+ end
218
+ ```
219
+
220
+ Every time a method is called, class and instance method events are instrumented, consumed and logged:
221
+
222
+ ```ruby
223
+ class Car
224
+ # Adds the helper methods to the class.
225
+ # All helpers prefixed with debug_*,
226
+ # except for the *notifies* decorator, which comes from extending DebugLogging::ClassNotifier
227
+ extend DebugLogging
228
+
229
+ # For instance methods:
230
+ # Option 1: specify the exact method(s) to add instrumentation to
231
+ # NOTE: You can capture instance variable values as part of the event payload
232
+ include DebugLogging::InstanceNotifier.new(i_methods: [:drive,
233
+ :stop,
234
+ [:turn, { instance_variables: %i[direction angle] }]])
235
+
236
+ # For class methods
237
+ # Provides the versatile `notifies` method decorator / macro
238
+ # For instance methods
239
+ # Provides the versatile `i_notifies` method decorator / macro
240
+ extend DebugLogging::ClassNotifier
241
+
242
+ # == BEGIN CLASS METHODS ==
243
+ # For class methods:
244
+ # Option 1: Use *notifies* as a method decorator
245
+ notifies def self.make; new; end
246
+ def self.design(*args); new; end
247
+ def self.safety(*args); new; end
248
+ def self.dealer_options(*args); new; end
249
+
250
+ # Option 2: Use *logged* as a macro
251
+ notifies :design, :safety
252
+ # Override configuration options for any class method(s), by passing a hash as the last argument
253
+ # In the last hash any non-Configuration keys will be data that gets added to the event payload,
254
+ # and also made available to last_hash_to_s_proc
255
+ notifies :dealer_options, {
256
+ something: 'here', # <= will be added to the event payload, and be available to last_hash_to_s_proc
257
+ add_invocation_id: false # <= Overrides config
258
+ }
259
+ def self.will_not_be_notified; false; end
260
+ # == END CLASS METHODS ==
261
+
262
+ # == BEGIN INSTANCE METHODS ==
263
+ def drive(speed); speed; end
264
+ def stop(**opts); 0; end
265
+
266
+ # For instance methods:
267
+ # Option 2: add instrumentation to all instance methods defined above (but *not* defined below)
268
+ include DebugLogging::InstanceNotifier.new(i_methods: self.instance_methods(false))
269
+
270
+ def faster(**opts); 0; end
271
+
272
+ # Override options for any instance method(s), by passing a hash as the last argument
273
+ # In the last hash any non-Configuration keys will be data that gets added to the event payload,
274
+ # and also made available to last_hash_to_s_proc
275
+ include DebugLogging::InstanceNotifier.new(i_methods: [:faster], config: { add_invocation_id: false })
174
276
 
277
+ def will_not_be_notified; false; end
278
+ # == END INSTANCE METHODS ==
175
279
  end
176
280
  ```
177
281
 
@@ -207,14 +311,14 @@ dependency on this gem using the [Pessimistic Version Constraint](http://docs.ru
207
311
  For example:
208
312
 
209
313
  ```ruby
210
- spec.add_dependency 'debug_logging', '~> 1.0'
314
+ spec.add_dependency 'debug_logging', '~> 3.1'
211
315
  ```
212
316
 
213
- ## License
317
+ ## License [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
214
318
 
215
319
  MIT License
216
320
 
217
- Copyright (c) 2017 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
321
+ Copyright (c) 2017 - 2020 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
218
322
 
219
323
  Permission is hereby granted, free of charge, to any person obtaining
220
324
  a copy of this software and associated documentation files (the
@@ -243,3 +347,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
243
347
  [angellist]: https://angel.co/peter-boling
244
348
  [documentation]: http://rdoc.info/github/pboling/debug_logging/frames
245
349
  [homepage]: https://github.com/pboling/debug_logging
350
+ [blogpage]: http://www.railsbling.com/tags/debug_logging/