debug_logging 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +8 -1
- data/README.md +65 -6
- data/debug_logging.gemspec +1 -0
- data/lib/debug_logging/active_support_notifications.rb +6 -0
- data/lib/debug_logging/argument_printer.rb +5 -1
- data/lib/debug_logging/class_notifier.rb +47 -0
- data/lib/debug_logging/configuration.rb +11 -4
- 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 +1 -1
- data/lib/simple_debug_logging.rb +0 -2
- metadata +27 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
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_todo.yml
CHANGED
@@ -33,7 +33,7 @@ Metrics/AbcSize:
|
|
33
33
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
|
34
34
|
# ExcludedMethods: refine
|
35
35
|
Metrics/BlockLength:
|
36
|
-
Max:
|
36
|
+
Max: 810
|
37
37
|
|
38
38
|
# Offense count: 6
|
39
39
|
# Configuration parameters: CountBlocks.
|
@@ -87,9 +87,13 @@ Style/Documentation:
|
|
87
87
|
- 'lib/debug_logging.rb'
|
88
88
|
- 'lib/debug_logging/argument_printer.rb'
|
89
89
|
- 'lib/debug_logging/class_logger.rb'
|
90
|
+
- 'lib/debug_logging/class_notifier.rb'
|
90
91
|
- 'lib/debug_logging/configuration.rb'
|
91
92
|
- 'lib/debug_logging/instance_logger.rb'
|
92
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'
|
93
97
|
- 'lib/simple_debug_logging.rb'
|
94
98
|
|
95
99
|
# Offense count: 1
|
@@ -99,6 +103,7 @@ Style/Documentation:
|
|
99
103
|
Style/EmptyElse:
|
100
104
|
Exclude:
|
101
105
|
- 'lib/debug_logging/class_logger.rb'
|
106
|
+
- 'lib/debug_logging/class_notifier.rb'
|
102
107
|
|
103
108
|
# Offense count: 2
|
104
109
|
# Configuration parameters: EnforcedStyle.
|
@@ -111,7 +116,9 @@ Style/FormatStringToken:
|
|
111
116
|
Style/IdenticalConditionalBranches:
|
112
117
|
Exclude:
|
113
118
|
- 'lib/debug_logging/class_logger.rb'
|
119
|
+
- 'lib/debug_logging/class_notifier.rb'
|
114
120
|
- 'lib/debug_logging/instance_logger_modulizer.rb'
|
121
|
+
- 'lib/debug_logging/instance_notifier_modulizer.rb'
|
115
122
|
|
116
123
|
# Offense count: 1
|
117
124
|
Style/MultilineBlockChain:
|
data/README.md
CHANGED
@@ -29,7 +29,9 @@ Unobtrusive, inheritable-overridable-configurable, drop-in debug logging, that w
|
|
29
29
|
* *single line config, per class/instance/method config*
|
30
30
|
* *separate logger, if needed*
|
31
31
|
* *log method calls, also when exit scope*
|
32
|
-
* *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*
|
33
35
|
* **so many free ponies** 🎠🐴🎠🐴🎠🐴
|
34
36
|
|
35
37
|
## Next Level Magic
|
@@ -40,7 +42,10 @@ Herein you will find:
|
|
40
42
|
* Zero tolerance policy on monkey patching
|
41
43
|
* 100% clean, 0% obtrusive
|
42
44
|
* 100% tested
|
43
|
-
* 100% Ruby 2.
|
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+
|
44
49
|
|
45
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.
|
46
51
|
|
@@ -62,8 +67,6 @@ Or install it yourself as:
|
|
62
67
|
|
63
68
|
## Usage
|
64
69
|
|
65
|
-
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.
|
66
|
-
|
67
70
|
Crack open the specs for more complex usage examples than the ones below.
|
68
71
|
|
69
72
|
### Without Rails
|
@@ -85,6 +88,7 @@ DebugLogging.configuration.last_hash_max_length = 1_000
|
|
85
88
|
DebugLogging.configuration.args_max_length = 1_000
|
86
89
|
DebugLogging.configuration.instance_benchmarks = false
|
87
90
|
DebugLogging.configuration.class_benchmarks = false
|
91
|
+
DebugLogging.configuration.active_support_notifications = false
|
88
92
|
DebugLogging.configuration.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
89
93
|
DebugLogging.configuration.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
90
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 }
|
@@ -104,6 +108,7 @@ DebugLogging.configure do |config|
|
|
104
108
|
config.args_max_length = 1_000
|
105
109
|
config.instance_benchmarks = false
|
106
110
|
config.class_benchmarks = false
|
111
|
+
config.active_support_notifications = false
|
107
112
|
config.colorized_chain_for_method = false # e.g. ->(colorized_string) { colorized_string.red.on_blue.underline }
|
108
113
|
config.colorized_chain_for_class = false # e.g. ->(colorized_string) { colorized_string.colorize(:light_blue ).colorize( :background => :red) }
|
109
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 }
|
@@ -127,7 +132,7 @@ Just send along a hash of the config options when you call `logged` or `include
|
|
127
132
|
DebugLogging.configuration.logger = Rails.logger
|
128
133
|
```
|
129
134
|
|
130
|
-
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:
|
131
136
|
|
132
137
|
```ruby
|
133
138
|
class Car
|
@@ -170,6 +175,60 @@ class Car
|
|
170
175
|
end
|
171
176
|
```
|
172
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
|
+
|
173
232
|
## Development
|
174
233
|
|
175
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.
|
@@ -202,7 +261,7 @@ dependency on this gem using the [Pessimistic Version Constraint](http://docs.ru
|
|
202
261
|
For example:
|
203
262
|
|
204
263
|
```ruby
|
205
|
-
spec.add_dependency 'debug_logging', '~>
|
264
|
+
spec.add_dependency 'debug_logging', '~> 3.1'
|
206
265
|
```
|
207
266
|
|
208
267
|
## License [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
|
data/debug_logging.gemspec
CHANGED
@@ -27,6 +27,7 @@ Automatically log selected methods and their arguments as they are called at run
|
|
27
27
|
spec.required_ruby_version = '>= 2.4.0' # Uses magic comments
|
28
28
|
|
29
29
|
spec.add_runtime_dependency 'colorize', '>= 0'
|
30
|
+
spec.add_development_dependency 'activesupport', '~> 5.2', '>= 5.2.4.4'
|
30
31
|
spec.add_development_dependency 'bundler', '>= 2'
|
31
32
|
spec.add_development_dependency 'byebug', '>= 11'
|
32
33
|
spec.add_development_dependency 'rake', '>= 13'
|
@@ -6,6 +6,10 @@ module DebugLogging
|
|
6
6
|
"completed in #{format('%f', tms.real)}s (#{format('%f', tms.total)}s CPU)"
|
7
7
|
end
|
8
8
|
|
9
|
+
def debug_event_name_to_s(method_to_notify: nil)
|
10
|
+
"#{method_to_notify}.log"
|
11
|
+
end
|
12
|
+
|
9
13
|
def debug_invocation_id_to_s(args: nil, config_proxy: nil)
|
10
14
|
if config_proxy.debug_add_invocation_id
|
11
15
|
invocation = " ~#{args.object_id}@#{(Time.now.to_f.to_s % '%#-21a')[4..-4]}~"
|
@@ -79,7 +83,7 @@ module DebugLogging
|
|
79
83
|
# handle double splat
|
80
84
|
printed_args += ("**#{args.map(&:inspect).join(', ').tap { |x| add_args_ellipsis = x.length > config_proxy.debug_args_max_length }}")[0..(config_proxy.debug_args_max_length)]
|
81
85
|
else
|
82
|
-
printed_args += args.map(&:inspect).join(', ').tap { |x| add_args_ellipsis = x.length > config_proxy.debug_args_max_length}[0..(config_proxy.debug_args_max_length)]
|
86
|
+
printed_args += args.map(&:inspect).join(', ').tap { |x| add_args_ellipsis = x.length > config_proxy.debug_args_max_length }[0..(config_proxy.debug_args_max_length)]
|
83
87
|
end
|
84
88
|
printed_args += config_proxy.debug_ellipsis if add_args_ellipsis
|
85
89
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DebugLogging
|
4
|
+
module ClassNotifier
|
5
|
+
def notifies(*methods_to_notify)
|
6
|
+
payload = methods_to_notify.last.is_a?(Hash) && methods_to_notify.pop || {}
|
7
|
+
if methods_to_notify.first.is_a?(Array)
|
8
|
+
methods_to_notify = methods_to_notify.shift
|
9
|
+
else
|
10
|
+
# logged :meth1, :meth2, :meth3 without options is valid too
|
11
|
+
end
|
12
|
+
methods_to_notify.each do |method_to_notify|
|
13
|
+
# method name must be a symbol
|
14
|
+
method_to_notify = method_to_notify.to_sym
|
15
|
+
original_method = method(method_to_notify)
|
16
|
+
config_proxy = nil
|
17
|
+
(class << self; self; end).class_eval do
|
18
|
+
define_method(method_to_notify) do |*args, &block|
|
19
|
+
config_proxy = if (proxy = instance_variable_get(DebugLogging::Configuration.config_pointer('k', method_to_notify)))
|
20
|
+
proxy
|
21
|
+
else
|
22
|
+
proxy = if !payload.empty?
|
23
|
+
Configuration.new(**debug_config.to_hash.merge(payload))
|
24
|
+
else
|
25
|
+
debug_config
|
26
|
+
end
|
27
|
+
proxy.register(method_to_notify)
|
28
|
+
instance_variable_set(DebugLogging::Configuration.config_pointer('k', method_to_notify), proxy)
|
29
|
+
proxy
|
30
|
+
end
|
31
|
+
ActiveSupport::Notifications.instrument(
|
32
|
+
debug_event_name_to_s(method_to_notify: method_to_notify), { args: args }.merge(payload)
|
33
|
+
) do
|
34
|
+
original_method.call(*args, &block)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
ActiveSupport::Notifications.subscribe(/log/) do |*args|
|
40
|
+
config_proxy&.log do
|
41
|
+
DebugLogging::LogSubscriber.log_event(ActiveSupport::Notifications::Event.new(*args))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -9,7 +9,7 @@ module DebugLogging
|
|
9
9
|
attr_accessor :logger, :log_level, :multiple_last_hashes, :last_hash_to_s_proc, :last_hash_max_length,
|
10
10
|
:args_max_length, :colorized_chain_for_method, :colorized_chain_for_class, :add_invocation_id,
|
11
11
|
:ellipsis, :mark_scope_exit
|
12
|
-
attr_reader :instance_benchmarks, :class_benchmarks, :methods_to_log
|
12
|
+
attr_reader :instance_benchmarks, :class_benchmarks, :active_support_notifications, :methods_to_log
|
13
13
|
# alias the readers to the debug_* prefix so an instance of this class
|
14
14
|
# can have the same API granted by `extend DebugLogging`
|
15
15
|
#
|
@@ -59,13 +59,14 @@ module DebugLogging
|
|
59
59
|
@last_hash_to_s_proc = options.key?(:last_hash_to_s_proc) ? options[:last_hash_to_s_proc] : nil
|
60
60
|
@last_hash_max_length = options.key?(:last_hash_max_length) ? options[:last_hash_max_length] : 1_000
|
61
61
|
@args_max_length = options.key?(:args_max_length) ? options[:args_max_length] : 1_000
|
62
|
-
@instance_benchmarks = options.key?(:instance_benchmarks) ? options[:instance_benchmarks] : false
|
63
|
-
@class_benchmarks = options.key?(:class_benchmarks) ? options[:class_benchmarks] : false
|
64
62
|
@colorized_chain_for_method = options.key?(:colorized_chain_for_method) ? options[:colorized_chain_for_method] : false
|
65
63
|
@colorized_chain_for_class = options.key?(:colorized_chain_for_class) ? options[:colorized_chain_for_class] : false
|
66
64
|
@add_invocation_id = options.key?(:add_invocation_id) ? options[:add_invocation_id] : true
|
67
65
|
@ellipsis = options.key?(:ellipsis) ? options[:ellipsis] : DEFAULT_ELLIPSIS
|
68
66
|
@mark_scope_exit = options.key?(:mark_scope_exit) ? options[:mark_scope_exit] : false
|
67
|
+
self.instance_benchmarks = options.key?(:instance_benchmarks) ? options[:instance_benchmarks] : false
|
68
|
+
self.class_benchmarks = options.key?(:class_benchmarks) ? options[:class_benchmarks] : false
|
69
|
+
self.active_support_notifications = options.key?(:active_support_notifications) ? options[:active_support_notifications] : false
|
69
70
|
@methods_to_log = []
|
70
71
|
end
|
71
72
|
|
@@ -108,6 +109,11 @@ module DebugLogging
|
|
108
109
|
@class_benchmarks = class_benchmarks
|
109
110
|
end
|
110
111
|
|
112
|
+
def active_support_notifications=(active_support_notifications)
|
113
|
+
require 'debug_logging/active_support_notifications' if active_support_notifications
|
114
|
+
@active_support_notifications = active_support_notifications
|
115
|
+
end
|
116
|
+
|
111
117
|
def to_hash
|
112
118
|
{
|
113
119
|
logger: logger,
|
@@ -122,7 +128,8 @@ module DebugLogging
|
|
122
128
|
colorized_chain_for_class: colorized_chain_for_class,
|
123
129
|
add_invocation_id: add_invocation_id,
|
124
130
|
ellipsis: ellipsis,
|
125
|
-
mark_scope_exit: mark_scope_exit
|
131
|
+
mark_scope_exit: mark_scope_exit,
|
132
|
+
active_support_notifications: active_support_notifications
|
126
133
|
}
|
127
134
|
end
|
128
135
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DebugLogging
|
4
|
+
class InstanceNotifier < Module
|
5
|
+
def initialize(i_methods: nil)
|
6
|
+
super()
|
7
|
+
@instance_methods_to_notify = Array(i_methods) if i_methods
|
8
|
+
end
|
9
|
+
|
10
|
+
def included(base)
|
11
|
+
return unless @instance_methods_to_notify
|
12
|
+
|
13
|
+
base.send(:include, ArgumentPrinter)
|
14
|
+
instance_method_notifier = DebugLogging::InstanceNotifierModulizer.to_mod(methods_to_notify: @instance_methods_to_notify)
|
15
|
+
base.send(:prepend, instance_method_notifier)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module DebugLogging
|
4
|
+
module InstanceNotifierModulizer
|
5
|
+
def self.to_mod(methods_to_notify: nil)
|
6
|
+
Module.new do
|
7
|
+
Array(methods_to_notify).each do |method_to_notify|
|
8
|
+
# method name must be a symbol
|
9
|
+
payload = method_to_notify.is_a?(Array) && method_to_notify.last.is_a?(Hash) && method_to_notify.pop || {}
|
10
|
+
if method_to_notify.is_a?(Array)
|
11
|
+
method_to_notify = method_to_notify.first&.to_sym
|
12
|
+
else
|
13
|
+
method_to_notify.to_sym
|
14
|
+
end
|
15
|
+
config_proxy = nil
|
16
|
+
define_method(method_to_notify) do |*args, &block|
|
17
|
+
config_proxy = if (proxy = instance_variable_get(DebugLogging::Configuration.config_pointer('i', method_to_notify)))
|
18
|
+
proxy
|
19
|
+
else
|
20
|
+
proxy = if !payload.empty?
|
21
|
+
Configuration.new(**self.class.debug_config.to_hash.merge(payload))
|
22
|
+
else
|
23
|
+
self.class.debug_config
|
24
|
+
end
|
25
|
+
proxy.register(method_to_notify)
|
26
|
+
instance_variable_set(DebugLogging::Configuration.config_pointer('i', method_to_notify), proxy)
|
27
|
+
proxy
|
28
|
+
end
|
29
|
+
if payload.key?(:instance_variables)
|
30
|
+
payload[:instance_variables].each do |k|
|
31
|
+
payload[k] = instance_variable_get("@#{k}") if instance_variable_get("@#{k}")
|
32
|
+
end
|
33
|
+
payload.delete(:instance_variables)
|
34
|
+
end
|
35
|
+
ActiveSupport::Notifications.instrument(
|
36
|
+
self.class.debug_event_name_to_s(method_to_notify: method_to_notify), { args: args }.merge(payload)
|
37
|
+
) do
|
38
|
+
super(*args, &block)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
ActiveSupport::Notifications.subscribe(/log/) do |*args|
|
43
|
+
config_proxy&.log do
|
44
|
+
DebugLogging::LogSubscriber.log_event(ActiveSupport::Notifications::Event.new(*args))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/log_subscriber'
|
4
|
+
|
5
|
+
module DebugLogging
|
6
|
+
class LogSubscriber < ActiveSupport::LogSubscriber
|
7
|
+
class << self
|
8
|
+
attr_accessor :event
|
9
|
+
end
|
10
|
+
attach_to :log
|
11
|
+
|
12
|
+
EVENT_FORMAT_STRING = '%<name>s (%<duration>.3f secs) start=%<time>s end=%<end>s payload=%<payload>s'
|
13
|
+
|
14
|
+
def self.log_event(event)
|
15
|
+
@event = event
|
16
|
+
if event.payload && event.payload[:exception_object]
|
17
|
+
exception = event.payload[:exception_object]
|
18
|
+
"#{event.name} [ERROR] : \n#{exception.class} : #{exception.message}\n" + exception.backtrace.join("\n")
|
19
|
+
end
|
20
|
+
format(EVENT_FORMAT_STRING, event_to_format_options(event))
|
21
|
+
end
|
22
|
+
|
23
|
+
# @param [ActiveSupport::Notifications::Event]
|
24
|
+
# @return [Hash]
|
25
|
+
def self.event_to_format_options(event)
|
26
|
+
{
|
27
|
+
name: event.name,
|
28
|
+
duration: Rational(event.duration, 1000).to_f,
|
29
|
+
time: event.time,
|
30
|
+
end: event.end,
|
31
|
+
payload: event.payload
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/simple_debug_logging.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: debug_logging
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Boling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -24,6 +24,26 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: activesupport
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.2'
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: 5.2.4.4
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '5.2'
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 5.2.4.4
|
27
47
|
- !ruby/object:Gem::Dependency
|
28
48
|
name: bundler
|
29
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -159,11 +179,16 @@ files:
|
|
159
179
|
- bin/setup
|
160
180
|
- debug_logging.gemspec
|
161
181
|
- lib/debug_logging.rb
|
182
|
+
- lib/debug_logging/active_support_notifications.rb
|
162
183
|
- lib/debug_logging/argument_printer.rb
|
163
184
|
- lib/debug_logging/class_logger.rb
|
185
|
+
- lib/debug_logging/class_notifier.rb
|
164
186
|
- lib/debug_logging/configuration.rb
|
165
187
|
- lib/debug_logging/instance_logger.rb
|
166
188
|
- lib/debug_logging/instance_logger_modulizer.rb
|
189
|
+
- lib/debug_logging/instance_notifier.rb
|
190
|
+
- lib/debug_logging/instance_notifier_modulizer.rb
|
191
|
+
- lib/debug_logging/log_subscriber.rb
|
167
192
|
- lib/debug_logging/version.rb
|
168
193
|
- lib/simple_debug_logging.rb
|
169
194
|
homepage: https://github.com/pboling/debug_logging
|