markdown_logging_proxy 1.3.0 → 1.3.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/dist/markdown_logging_proxy.rb +37 -9
- data/lib/markdown_logging_proxy/tracer.rb +37 -9
- data/markdown_logging_proxy.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e893add5ca96b98f32be5370fb7bfc61e3f80f387392359b4c8e25f9d7e1ca45
|
4
|
+
data.tar.gz: 37dd7b894552ba38329279dcb2c8ef23961ca719c23ba1f7a5343e0e1c365c89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd08c3cecf05ef6173ae54c8cd9885e2817c94c141fd3c168c1a04f79f9c267e9fbaebb164cf00ba6670125f4dafd0135a47d39b758b11b043feabf851bf9e8d
|
7
|
+
data.tar.gz: '096efff296da1406507b5f2a5531bbf267324a4b53c27ce7ced1b05f85e59b223480e5cb21838b658937a00093cad8e2d961f1c6727a48e85bf3ecf06a9797bb'
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -151,14 +151,20 @@ module MarkdownLoggingProxy
|
|
151
151
|
@ignore.member?(meth)
|
152
152
|
end
|
153
153
|
|
154
|
-
def inspect_object(obj,
|
154
|
+
def inspect_object(obj, args: false)
|
155
155
|
obj_str =
|
156
156
|
case inspect_method
|
157
157
|
when :inspect then obj.inspect
|
158
|
-
when :
|
158
|
+
when :limited then limited_inspect(obj)
|
159
|
+
when :id_object
|
160
|
+
if args
|
161
|
+
"[#{obj.map { |o| id_object(o) }.join(',')}]"
|
162
|
+
else
|
163
|
+
id_object(obj)
|
164
|
+
end
|
159
165
|
when :pretty_inpect
|
160
166
|
[obj.pretty_inspect.chomp].tap do |lines|
|
161
|
-
lines.prepend "# #{
|
167
|
+
lines.prepend "# #{id_object(obj)}" unless args
|
162
168
|
end.join("\n")
|
163
169
|
else
|
164
170
|
obj.send(inspect_method)
|
@@ -166,9 +172,31 @@ module MarkdownLoggingProxy
|
|
166
172
|
['```ruby', obj_str, '```'].join("\n")
|
167
173
|
end
|
168
174
|
|
175
|
+
# recursive
|
176
|
+
def limited_inspect(obj)
|
177
|
+
case obj
|
178
|
+
when Array
|
179
|
+
"[#{obj.map { |o| limited_inspect(o) }.join(',')}]"
|
180
|
+
when Hash
|
181
|
+
# assumes keys are safe to .inspect
|
182
|
+
insides = obj.each { |k, v| "#{k.inspect} => #{limited_inspect(v)}" }
|
183
|
+
"{#{insides.join(', ')}}"
|
184
|
+
when String, Symbol, Numeric, Class, true, false, nil
|
185
|
+
truncated_inspect(obj)
|
186
|
+
else
|
187
|
+
id_object(obj)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
169
191
|
def id_object(object)
|
170
192
|
# #<Object:0xe140>
|
171
|
-
"
|
193
|
+
"#<#{object.class}:0x#{object.object_id.to_s(16)}>"
|
194
|
+
end
|
195
|
+
|
196
|
+
def truncated_inspect(obj, limit = 280)
|
197
|
+
obj_str = obj.inspect
|
198
|
+
obj_str = "#{obj_str.first(limit)}..." if obj_str.length > limit
|
199
|
+
obj_str
|
172
200
|
end
|
173
201
|
|
174
202
|
private
|
@@ -176,11 +204,11 @@ module MarkdownLoggingProxy
|
|
176
204
|
def log_call_signature(meth, args, &blk)
|
177
205
|
return if ignore.member?(meth)
|
178
206
|
logger.log :info, 1, <<~MSG.chomp
|
179
|
-
Calling `#{meth}` on
|
207
|
+
Calling `#{meth}` on `#{id_object(target)}`
|
180
208
|
|
181
209
|
Arguments:
|
182
210
|
|
183
|
-
#{inspect_object(args,
|
211
|
+
#{inspect_object(args, args: true)}
|
184
212
|
|
185
213
|
Block given? #{block_given? ? 'Yes' : 'No'}
|
186
214
|
#{logger.inspect_backtrace}
|
@@ -194,7 +222,7 @@ module MarkdownLoggingProxy
|
|
194
222
|
logger.log :info, 3, <<~MSG.chomp
|
195
223
|
Returning proxied response to `#{meth}`
|
196
224
|
|
197
|
-
Proxy from `#{meth}` on
|
225
|
+
Proxy from `#{meth}` on `#{id_object(target)}`
|
198
226
|
|
199
227
|
Proxy for:
|
200
228
|
|
@@ -214,11 +242,11 @@ module MarkdownLoggingProxy
|
|
214
242
|
tracer = self
|
215
243
|
proc do |*args|
|
216
244
|
tracer.logger.log :info, 2, <<~MSG.chomp
|
217
|
-
Yield to block in `#{meth}` on
|
245
|
+
Yield to block in `#{meth}` on `#{tracer.id_object(tracer.target)}`
|
218
246
|
|
219
247
|
Arguments:
|
220
248
|
|
221
|
-
#{tracer.inspect_object(args,
|
249
|
+
#{tracer.inspect_object(args, args: true)}
|
222
250
|
MSG
|
223
251
|
instance_exec(*args, &blk).tap do |response|
|
224
252
|
tracer.logger.log :info, 3, <<~MSG.chomp
|
@@ -38,14 +38,20 @@ module MarkdownLoggingProxy
|
|
38
38
|
@ignore.member?(meth)
|
39
39
|
end
|
40
40
|
|
41
|
-
def inspect_object(obj,
|
41
|
+
def inspect_object(obj, args: false)
|
42
42
|
obj_str =
|
43
43
|
case inspect_method
|
44
44
|
when :inspect then obj.inspect
|
45
|
-
when :
|
45
|
+
when :limited then limited_inspect(obj)
|
46
|
+
when :id_object
|
47
|
+
if args
|
48
|
+
"[#{obj.map { |o| id_object(o) }.join(',')}]"
|
49
|
+
else
|
50
|
+
id_object(obj)
|
51
|
+
end
|
46
52
|
when :pretty_inpect
|
47
53
|
[obj.pretty_inspect.chomp].tap do |lines|
|
48
|
-
lines.prepend "# #{
|
54
|
+
lines.prepend "# #{id_object(obj)}" unless args
|
49
55
|
end.join("\n")
|
50
56
|
else
|
51
57
|
obj.send(inspect_method)
|
@@ -53,9 +59,31 @@ module MarkdownLoggingProxy
|
|
53
59
|
['```ruby', obj_str, '```'].join("\n")
|
54
60
|
end
|
55
61
|
|
62
|
+
# recursive
|
63
|
+
def limited_inspect(obj)
|
64
|
+
case obj
|
65
|
+
when Array
|
66
|
+
"[#{obj.map { |o| limited_inspect(o) }.join(',')}]"
|
67
|
+
when Hash
|
68
|
+
# assumes keys are safe to .inspect
|
69
|
+
insides = obj.each { |k, v| "#{k.inspect} => #{limited_inspect(v)}" }
|
70
|
+
"{#{insides.join(', ')}}"
|
71
|
+
when String, Symbol, Numeric, Class, true, false, nil
|
72
|
+
truncated_inspect(obj)
|
73
|
+
else
|
74
|
+
id_object(obj)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
56
78
|
def id_object(object)
|
57
79
|
# #<Object:0xe140>
|
58
|
-
"
|
80
|
+
"#<#{object.class}:0x#{object.object_id.to_s(16)}>"
|
81
|
+
end
|
82
|
+
|
83
|
+
def truncated_inspect(obj, limit = 280)
|
84
|
+
obj_str = obj.inspect
|
85
|
+
obj_str = "#{obj_str.first(limit)}..." if obj_str.length > limit
|
86
|
+
obj_str
|
59
87
|
end
|
60
88
|
|
61
89
|
private
|
@@ -63,11 +91,11 @@ module MarkdownLoggingProxy
|
|
63
91
|
def log_call_signature(meth, args, &blk)
|
64
92
|
return if ignore.member?(meth)
|
65
93
|
logger.log :info, 1, <<~MSG.chomp
|
66
|
-
Calling `#{meth}` on
|
94
|
+
Calling `#{meth}` on `#{id_object(target)}`
|
67
95
|
|
68
96
|
Arguments:
|
69
97
|
|
70
|
-
#{inspect_object(args,
|
98
|
+
#{inspect_object(args, args: true)}
|
71
99
|
|
72
100
|
Block given? #{block_given? ? 'Yes' : 'No'}
|
73
101
|
#{logger.inspect_backtrace}
|
@@ -81,7 +109,7 @@ module MarkdownLoggingProxy
|
|
81
109
|
logger.log :info, 3, <<~MSG.chomp
|
82
110
|
Returning proxied response to `#{meth}`
|
83
111
|
|
84
|
-
Proxy from `#{meth}` on
|
112
|
+
Proxy from `#{meth}` on `#{id_object(target)}`
|
85
113
|
|
86
114
|
Proxy for:
|
87
115
|
|
@@ -101,11 +129,11 @@ module MarkdownLoggingProxy
|
|
101
129
|
tracer = self
|
102
130
|
proc do |*args|
|
103
131
|
tracer.logger.log :info, 2, <<~MSG.chomp
|
104
|
-
Yield to block in `#{meth}` on
|
132
|
+
Yield to block in `#{meth}` on `#{tracer.id_object(tracer.target)}`
|
105
133
|
|
106
134
|
Arguments:
|
107
135
|
|
108
|
-
#{tracer.inspect_object(args,
|
136
|
+
#{tracer.inspect_object(args, args: true)}
|
109
137
|
MSG
|
110
138
|
instance_exec(*args, &blk).tap do |response|
|
111
139
|
tracer.logger.log :info, 3, <<~MSG.chomp
|