debugtrace 0.2.0 → 0.2.2
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/lib/debugtrace/config.rb +2 -2
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +21 -40
- 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: 5937a3c3f6b9d19ab3bb040ef763ada32e262c5046532331a7082f3edc3128cb
|
4
|
+
data.tar.gz: 31b5c3027993f50d06409ec9c54d55adff5e68563a8f02b66ae6e618027ec550
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33e2b5d74dcfcabfc0868652118694478e47ad5c6066e70c75090b50db7dc61008cfdfe5d4a9b438d7d7a2df91be97110d3766bfbbbd43536dfbaeacf0414c22
|
7
|
+
data.tar.gz: bd78a8be204cd636d3104d06e3ff777ade2458f0492c5e50fd6f115f7108d290d4348cf02454721ca2680ef6a872455122b50e95fa836e8f9ed7efb1a17e7e6b
|
data/lib/debugtrace/config.rb
CHANGED
@@ -38,7 +38,7 @@ class Config
|
|
38
38
|
@collection_limit = _get_config_value 'collection_limit' , 128
|
39
39
|
@bytes_limit = _get_config_value 'bytes_limit' , 256
|
40
40
|
@string_limit = _get_config_value 'string_limit' , 256
|
41
|
-
@
|
41
|
+
@reflection_limit = _get_config_value 'reflection_limit' , 4
|
42
42
|
end
|
43
43
|
|
44
44
|
attr_reader :config_path, :logger_name, :logging_destination, :logging_format, :logging_datetime_format,
|
@@ -47,7 +47,7 @@ class Config
|
|
47
47
|
:cyclic_reference_string, :varname_value_separator, :key_value_separator,
|
48
48
|
:print_suffix_format, :count_format, :minimum_output_count, :length_format,
|
49
49
|
:minimum_output_length, :maximum_data_output_width, :bytes_count_in_line,
|
50
|
-
:collection_limit, :bytes_limit, :string_limit, :
|
50
|
+
:collection_limit, :bytes_limit, :string_limit, :reflection_limit
|
51
51
|
|
52
52
|
def enabled? = @enabled
|
53
53
|
|
data/lib/debugtrace/version.rb
CHANGED
data/lib/debugtrace.rb
CHANGED
@@ -64,27 +64,23 @@ module DebugTrace
|
|
64
64
|
end
|
65
65
|
|
66
66
|
class PrintOptions
|
67
|
-
attr_reader :
|
68
|
-
|
69
|
-
:minimum_output_count, :minimum_output_length,
|
70
|
-
:collection_limit, :bytes_limit, :string_limit, :reflection_nest_limit
|
67
|
+
attr_reader :minimum_output_count, :minimum_output_length,
|
68
|
+
:collection_limit, :bytes_limit, :string_limit, :reflection_limit
|
71
69
|
|
72
70
|
def initialize(
|
73
|
-
force_reflection,
|
74
71
|
minimum_output_count,
|
75
72
|
minimum_output_length,
|
76
73
|
collection_limit,
|
77
74
|
bytes_limit,
|
78
75
|
string_limit,
|
79
|
-
|
76
|
+
reflection_limit
|
80
77
|
)
|
81
|
-
@force_reflection = force_reflection
|
82
78
|
@minimum_output_count = minimum_output_count == -1 ? DebugTrace.config.minimum_output_count : minimum_output_count
|
83
79
|
@minimum_output_length = minimum_output_length == -1 ? DebugTrace.config.minimum_output_length : minimum_output_length
|
84
80
|
@collection_limit = collection_limit == -1 ? DebugTrace.config.collection_limit : collection_limit
|
85
81
|
@bytes_limit = bytes_limit == -1 ? DebugTrace.config.bytes_limit : bytes_limit
|
86
82
|
@string_limit = string_limit == -1 ? DebugTrace.config.string_limit : string_limit
|
87
|
-
@
|
83
|
+
@reflection_limit = reflection_limit == -1 ? DebugTrace.config.reflection_limit : reflection_limit
|
88
84
|
end
|
89
85
|
end
|
90
86
|
|
@@ -118,50 +114,36 @@ module DebugTrace
|
|
118
114
|
|
119
115
|
case value
|
120
116
|
when nil
|
121
|
-
# nil
|
122
117
|
buff.no_break_append(separator).append('nil')
|
123
|
-
when
|
124
|
-
|
118
|
+
when FalseClass, TrueClass, Integer, Float
|
119
|
+
buff.no_break_append(separator).append(value.to_s)
|
120
|
+
when String
|
125
121
|
value_buff = to_string_str(value, print_options)
|
126
122
|
buff.append_buffer(separator, value_buff)
|
127
123
|
when DateTime
|
128
|
-
# DateTime
|
129
124
|
buff.no_break_append(separator).append(value.strftime('%Y-%m-%d %H:%M-%S.%L%:z'))
|
130
125
|
when Date
|
131
|
-
# DateTime
|
132
126
|
buff.no_break_append(separator).append(value.strftime('%Y-%m-%d'))
|
133
127
|
when Time
|
134
|
-
# DateTime
|
135
128
|
buff.no_break_append(separator).append(value.strftime('%H:%M-%S.%L%:z'))
|
136
|
-
when Integer, Float
|
137
|
-
# Integer, Float, Date, Time
|
138
|
-
buff.no_break_append(separator).append(value.to_s)
|
139
129
|
when Array, Set, Hash
|
140
|
-
# Array, Set, Hash
|
141
130
|
value_buff = to_string_enumerable(value, print_options)
|
142
131
|
buff.append_buffer(separator, value_buff)
|
143
132
|
else
|
133
|
+
# use reflection
|
144
134
|
value_buff = LogBuffer.new(@@config.maximum_data_output_width)
|
145
|
-
if
|
146
|
-
#
|
147
|
-
value_buff.
|
148
|
-
|
149
|
-
|
135
|
+
if @@reflected_objects.any? { |obj| value.equal?(obj) }
|
136
|
+
# cyclic reference
|
137
|
+
value_buff.no_break_append(@@config.cyclic_reference_string)
|
138
|
+
elsif @@reflected_objects.length > print_options.reflection_limit
|
139
|
+
# over reflection level limitation
|
140
|
+
value_buff.no_break_append(@@config.limit_string)
|
150
141
|
else
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
value_buff.no_break_append(@@config.cyclic_reference_string)
|
155
|
-
elsif @@reflected_objects.length > print_options.reflection_nest_limit
|
156
|
-
# over reflection level limitation
|
157
|
-
value_buff.no_break_append(@@config.limit_string)
|
158
|
-
else
|
159
|
-
@@reflected_objects.push(value)
|
160
|
-
value_buff = to_string_reflection(value, print_options)
|
161
|
-
@@reflected_objects.pop
|
162
|
-
end
|
163
|
-
buff.append_buffer(separator, value_buff)
|
142
|
+
@@reflected_objects.push(value)
|
143
|
+
value_buff = to_string_reflection(value, print_options)
|
144
|
+
@@reflected_objects.pop
|
164
145
|
end
|
146
|
+
buff.append_buffer(separator, value_buff)
|
165
147
|
end
|
166
148
|
|
167
149
|
buff
|
@@ -470,10 +452,10 @@ module DebugTrace
|
|
470
452
|
|
471
453
|
@@DO_NOT_OUTPUT = 'Do not output'
|
472
454
|
|
473
|
-
def self.print(name, value = @@DO_NOT_OUTPUT,
|
455
|
+
def self.print(name, value = @@DO_NOT_OUTPUT,
|
474
456
|
minimum_output_count: -1, minimum_output_length: -1,
|
475
457
|
collection_limit: -1, bytes_limit: -1,
|
476
|
-
string_limit: -1,
|
458
|
+
string_limit: -1, reflection_limit: -1)
|
477
459
|
@@thread_mutex.synchronize do
|
478
460
|
print_start
|
479
461
|
return value unless @@config.enabled?
|
@@ -490,10 +472,9 @@ module DebugTrace
|
|
490
472
|
else
|
491
473
|
# with value
|
492
474
|
print_options = PrintOptions.new(
|
493
|
-
force_reflection,
|
494
475
|
minimum_output_count, minimum_output_length,
|
495
476
|
collection_limit, bytes_limit,
|
496
|
-
string_limit,
|
477
|
+
string_limit, reflection_limit
|
497
478
|
)
|
498
479
|
@@last_log_buff = to_string(name, value, print_options)
|
499
480
|
end
|