debug_logging 1.0.15 → 3.1.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 +5 -5
- data/.rubocop.yml +99 -0
- data/.rubocop_todo.yml +133 -0
- data/.travis.yml +34 -5
- data/Gemfile +8 -2
- data/README.md +94 -39
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/debug_logging.gemspec +24 -20
- data/lib/debug_logging.rb +47 -11
- data/lib/debug_logging/active_support_notifications.rb +6 -0
- data/lib/debug_logging/argument_printer.rb +46 -33
- data/lib/debug_logging/class_logger.rb +4 -2
- data/lib/debug_logging/class_notifier.rb +47 -0
- data/lib/debug_logging/configuration.rb +64 -48
- data/lib/debug_logging/instance_logger.rb +5 -0
- data/lib/debug_logging/instance_logger_modulizer.rb +4 -2
- data/lib/debug_logging/instance_notifier.rb +18 -0
- data/lib/debug_logging/instance_notifier_modulizer.rb +51 -0
- data/lib/debug_logging/log_subscriber.rb +35 -0
- data/lib/debug_logging/version.rb +3 -1
- data/lib/simple_debug_logging.rb +7 -5
- metadata +88 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: efda45f99c32dcb0acc32896a61f2d209c527cf62bd74a74282cf044607f396f
|
4
|
+
data.tar.gz: d4af27fc700abaa9a536d15c56af36f8a202db7c40d0107a8d8eb1262252aaeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d857b33f90f75e8bdfb3f2deedfb5c503bd90adbabb6b9aead0ecb305ba72715c25435f9d543ff8471454b5c9c5ff631792b870a97864fdb30e530ba4c0e6fb0
|
7
|
+
data.tar.gz: 6985ed5caff4dbe017946a61b4f4242867110bcafcf266b62c98ce340d8af28f148b1dee364d3291296d2d5444789a429b254bedcd54bd63be28e4ce5a771b10
|
data/.rubocop.yml
ADDED
@@ -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
|
data/.rubocop_todo.yml
ADDED
@@ -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
|
data/.travis.yml
CHANGED
@@ -1,7 +1,36 @@
|
|
1
|
-
|
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.
|
5
|
-
- ruby-2.
|
6
|
-
-
|
7
|
-
|
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,26 @@
|
|
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
|
+
| Project | DebugLogging |
|
6
|
+
|------------------------ | ----------------------- |
|
7
|
+
| gem name | [debug_logging](https://rubygems.org/gems/debug_logging) |
|
8
|
+
| compatibility | Ruby 2.4, 2.5, 2.6, 2.7 |
|
9
|
+
| license | [](https://opensource.org/licenses/MIT) |
|
10
|
+
| download rank | [](https://github.com/pboling/debug_logging) |
|
11
|
+
| version | [](https://rubygems.org/gems/debug_logging) |
|
12
|
+
| dependencies | [](https://depfu.com/github/pboling/debug_logging?project_id=2675) |
|
13
|
+
| continuous integration | [](https://travis-ci.org/pboling/debug_logging) |
|
14
|
+
| test coverage | [](https://codeclimate.com/github/pboling/debug_logging/test_coverage) |
|
15
|
+
| maintainability | [](https://codeclimate.com/github/pboling/debug_logging/maintainability) |
|
16
|
+
| code triage | [](https://www.codetriage.com/pboling/debug_logging) |
|
17
|
+
| homepage | [on Github.com][homepage], [on Railsbling.com][blogpage] |
|
18
|
+
| documentation | [on RDoc.info][documentation] |
|
19
|
+
| live chat | [](https://gitter.im/pboling/debug_logging?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) |
|
20
|
+
| expert support | [](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
21
|
+
| Spread ~♡ⓛⓞⓥⓔ♡~ | [🌏](https://about.me/peter.boling), [👼](https://angel.co/peter-boling), [:shipit:](http://coderwall.com/pboling), [](http://twitter.com/galtzo), [🌹](https://nationalprogressiveparty.org) |
|
22
|
+
|
5
23
|
### Gives you (all are optional):
|
24
|
+
|
6
25
|
* *benchmarking*
|
7
26
|
* *colorization by class/method*
|
8
27
|
* *robust argument printer with customizable ellipsis*
|
@@ -10,45 +29,26 @@ Unobtrusive, inheritable-overridable-configurable, drop-in debug logging, that w
|
|
10
29
|
* *single line config, per class/instance/method config*
|
11
30
|
* *separate logger, if needed*
|
12
31
|
* *log method calls, also when exit scope*
|
13
|
-
* *Prevents heavy computation of strings with `logger.debug { 'log me' }` block format
|
32
|
+
* *Prevents heavy computation of strings with `logger.debug { 'log me' }` block format, since v1.0.12*
|
33
|
+
* *ActiveSupport::Notifications integration for instrumenting/logging events on class and instance methods, since v3.1*
|
34
|
+
* *Optional instance variable logging, sine v3.1*
|
14
35
|
* **so many free ponies** 🎠🐴🎠🐴🎠🐴
|
15
36
|
|
16
|
-
| Project | DebugLogging |
|
17
|
-
|------------------------ | ----------------- |
|
18
|
-
| gem name | debug_logging |
|
19
|
-
| license | [](https://opensource.org/licenses/MIT) |
|
20
|
-
| expert support | [](https://www.codementor.io/peterboling?utm_source=github&utm_medium=button&utm_term=peterboling&utm_campaign=github) |
|
21
|
-
| download rank | [](https://rubygems.org/gems/debug_logging) |
|
22
|
-
| version | [](http://badge.fury.io/rb/debug_logging) |
|
23
|
-
| dependencies | [](https://gemnasium.com/pboling/debug_logging) |
|
24
|
-
| code quality | [](https://codeclimate.com/github/pboling/debug_logging) |
|
25
|
-
| continuous integration | [](https://travis-ci.org/pboling/debug_logging) |
|
26
|
-
| test coverage | [](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 | [](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
37
|
## Next Level Magic
|
33
38
|
|
34
|
-
|
35
39
|
Herein you will find:
|
36
40
|
|
37
|
-
* Classes inheriting from Module
|
38
|
-
*
|
39
|
-
*
|
40
|
-
* 100%
|
41
|
-
* 100%
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
* Classes inheriting from Module
|
42
|
+
* Zero tolerance policy on monkey patching
|
43
|
+
* 100% clean, 0% obtrusive
|
44
|
+
* 100% tested
|
45
|
+
* 100% Ruby 2.1+ compatible
|
46
|
+
- use version ~1.0 for Ruby < 2.3
|
47
|
+
- use version ~2.0 for Ruby 2.3
|
48
|
+
- use version ~3.0 for Ruby 2.4+
|
45
49
|
|
46
50
|
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
51
|
|
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
52
|
## Installation
|
53
53
|
|
54
54
|
Add this line to your application's Gemfile:
|
@@ -67,18 +67,16 @@ Or install it yourself as:
|
|
67
67
|
|
68
68
|
## Usage
|
69
69
|
|
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
70
|
Crack open the specs for more complex usage examples than the ones below.
|
73
71
|
|
74
72
|
### Without Rails
|
75
73
|
|
76
74
|
It just works. ;)
|
77
|
-
Configuration can go anywhere you want.
|
75
|
+
Configuration can go anywhere you want. Configuration is the same regardless; see below.
|
78
76
|
|
79
77
|
### With Rails
|
80
78
|
|
81
|
-
Recommend creating `config/initializers/debug_logging.rb` with:
|
79
|
+
Recommend creating `config/initializers/debug_logging.rb`, or adding to `config/application.rb` with:
|
82
80
|
|
83
81
|
```ruby
|
84
82
|
# Showing the defaults
|
@@ -90,6 +88,7 @@ DebugLogging.configuration.last_hash_max_length = 1_000
|
|
90
88
|
DebugLogging.configuration.args_max_length = 1_000
|
91
89
|
DebugLogging.configuration.instance_benchmarks = false
|
92
90
|
DebugLogging.configuration.class_benchmarks = false
|
91
|
+
DebugLogging.configuration.active_support_notifications = false
|
93
92
|
DebugLogging.configuration.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
94
93
|
DebugLogging.configuration.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
95
94
|
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 +108,7 @@ DebugLogging.configure do |config|
|
|
109
108
|
config.args_max_length = 1_000
|
110
109
|
config.instance_benchmarks = false
|
111
110
|
config.class_benchmarks = false
|
111
|
+
config.active_support_notifications = false
|
112
112
|
config.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
113
113
|
config.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
114
114
|
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 +124,7 @@ Just prepend `debug_` to any config value you want to override in a class.
|
|
124
124
|
Just prepend `debug_` to any config value you want to override on an instance of a class.
|
125
125
|
|
126
126
|
**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
|
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.
|
128
128
|
|
129
129
|
**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
130
|
|
@@ -132,7 +132,7 @@ Just send along a hash of the config options when you call `logged` or `include
|
|
132
132
|
DebugLogging.configuration.logger = Rails.logger
|
133
133
|
```
|
134
134
|
|
135
|
-
Every time a method is called, get logs, optionally with arguments, a
|
135
|
+
Every time a method is called, you can now get logs, optionally with arguments, a benchmark, and a unique invocation identifier:
|
136
136
|
|
137
137
|
```ruby
|
138
138
|
class Car
|
@@ -175,6 +175,60 @@ class Car
|
|
175
175
|
end
|
176
176
|
```
|
177
177
|
|
178
|
+
### ActiveSupport::Notifications integration
|
179
|
+
|
180
|
+
To use `ActiveSupport::Notifications` integration, enable `active_support_notifications` in the config, either single line or block style:
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
DebugLogging.configuration.active_support_notifications = true
|
184
|
+
```
|
185
|
+
|
186
|
+
or
|
187
|
+
|
188
|
+
```ruby
|
189
|
+
DebugLogging.configure do |config|
|
190
|
+
config.active_support_notifications = true
|
191
|
+
end
|
192
|
+
```
|
193
|
+
|
194
|
+
Every time a method is called, class and instance method events are instrumented, consumed and logged:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
class Car
|
198
|
+
|
199
|
+
# adds the helper methods to the class, all are prefixed with debug_*,
|
200
|
+
# except for the instrumented class method, which comes from extending DebugLogging::ClassNotifier
|
201
|
+
extend DebugLogging
|
202
|
+
|
203
|
+
# For instance methods:
|
204
|
+
# Option 1: specify the exact method(s) to add instrumentation to (including capturing instance variable values as part of the event payload)
|
205
|
+
include DebugLogging::InstanceNotifier.new(i_methods: [:drive,
|
206
|
+
:stop,
|
207
|
+
[:turn, { instance_variables: %i[direction angle] }]])
|
208
|
+
|
209
|
+
# Provides the `notifies` method decorator
|
210
|
+
extend DebugLogging::ClassNotifier
|
211
|
+
|
212
|
+
notifies def make; new; end
|
213
|
+
def design(*args); new; end
|
214
|
+
def safety(*args); new; end
|
215
|
+
def dealer_options(*args); new; end
|
216
|
+
notifies :design, :safety
|
217
|
+
# adding additional event payload options for any instance method(s), by passing a hash as the last argument
|
218
|
+
notifies :dealer_options, { sport_package: true }
|
219
|
+
|
220
|
+
def drive(speed); speed; end
|
221
|
+
def stop(**opts); 0; end
|
222
|
+
|
223
|
+
# For instance methods:
|
224
|
+
# Option 2: add instrumentation to all instance methods defined above (but *not* defined below)
|
225
|
+
include DebugLogging::InstanceNotifier.new(i_methods: self.instance_methods(false))
|
226
|
+
|
227
|
+
def will_not_be_logged; false; end
|
228
|
+
|
229
|
+
end
|
230
|
+
```
|
231
|
+
|
178
232
|
## Development
|
179
233
|
|
180
234
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -207,14 +261,14 @@ dependency on this gem using the [Pessimistic Version Constraint](http://docs.ru
|
|
207
261
|
For example:
|
208
262
|
|
209
263
|
```ruby
|
210
|
-
spec.add_dependency 'debug_logging', '~> 1
|
264
|
+
spec.add_dependency 'debug_logging', '~> 3.1'
|
211
265
|
```
|
212
266
|
|
213
|
-
## License
|
267
|
+
## License [](https://opensource.org/licenses/MIT)
|
214
268
|
|
215
269
|
MIT License
|
216
270
|
|
217
|
-
Copyright (c) 2017 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
|
271
|
+
Copyright (c) 2017 - 2020 [Peter Boling][peterboling] of [RailsBling.com][railsbling]
|
218
272
|
|
219
273
|
Permission is hereby granted, free of charge, to any person obtaining
|
220
274
|
a copy of this software and associated documentation files (the
|
@@ -243,3 +297,4 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
243
297
|
[angellist]: https://angel.co/peter-boling
|
244
298
|
[documentation]: http://rdoc.info/github/pboling/debug_logging/frames
|
245
299
|
[homepage]: https://github.com/pboling/debug_logging
|
300
|
+
[blogpage]: http://www.railsbling.com/tags/debug_logging/
|