debugtrace 0.2.0 → 0.2.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/lib/debugtrace/config.rb +2 -2
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +15 -23
- 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: 45808a8d698423fb10b4b53bf1a0152b747a85a2ae32bab2ac42aff32a5252ed
|
4
|
+
data.tar.gz: 6a0aeb4db13f194c971b974110ee03b21e8dbb2baab8840a5c9a820142d4e05c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79b136be33532e002ab16bf327519d13567e50d49ab4d4fecfc3dfb588b207ae70cc55cf6fc89b4a51649e100dcb38f808f648326882487813ea01d9779dc735
|
7
|
+
data.tar.gz: 27e016acdd8748683c8afc0639be04b9efa2dffe593a9a8a714c849bfdcfeb86dbd7e9c1d0e133b72687636812b02730dadf2ff651fb53d6b592001b443e1cb9
|
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,26 @@ module DebugTrace
|
|
64
64
|
end
|
65
65
|
|
66
66
|
class PrintOptions
|
67
|
-
attr_reader :
|
68
|
-
# :output_private, :output_method,
|
67
|
+
attr_reader :reflection,
|
69
68
|
:minimum_output_count, :minimum_output_length,
|
70
|
-
:collection_limit, :bytes_limit, :string_limit, :
|
69
|
+
:collection_limit, :bytes_limit, :string_limit, :reflection_limit
|
71
70
|
|
72
71
|
def initialize(
|
73
|
-
|
72
|
+
reflection,
|
74
73
|
minimum_output_count,
|
75
74
|
minimum_output_length,
|
76
75
|
collection_limit,
|
77
76
|
bytes_limit,
|
78
77
|
string_limit,
|
79
|
-
|
78
|
+
reflection_limit
|
80
79
|
)
|
81
|
-
@
|
80
|
+
@reflection = reflection
|
82
81
|
@minimum_output_count = minimum_output_count == -1 ? DebugTrace.config.minimum_output_count : minimum_output_count
|
83
82
|
@minimum_output_length = minimum_output_length == -1 ? DebugTrace.config.minimum_output_length : minimum_output_length
|
84
83
|
@collection_limit = collection_limit == -1 ? DebugTrace.config.collection_limit : collection_limit
|
85
84
|
@bytes_limit = bytes_limit == -1 ? DebugTrace.config.bytes_limit : bytes_limit
|
86
85
|
@string_limit = string_limit == -1 ? DebugTrace.config.string_limit : string_limit
|
87
|
-
@
|
86
|
+
@reflection_limit = reflection_limit == -1 ? DebugTrace.config.reflection_limit : reflection_limit
|
88
87
|
end
|
89
88
|
end
|
90
89
|
|
@@ -118,31 +117,24 @@ module DebugTrace
|
|
118
117
|
|
119
118
|
case value
|
120
119
|
when nil
|
121
|
-
# nil
|
122
120
|
buff.no_break_append(separator).append('nil')
|
123
|
-
when
|
124
|
-
|
121
|
+
when FalseClass, TrueClass, Integer, Float
|
122
|
+
buff.no_break_append(separator).append(value.to_s)
|
123
|
+
when String
|
125
124
|
value_buff = to_string_str(value, print_options)
|
126
125
|
buff.append_buffer(separator, value_buff)
|
127
126
|
when DateTime
|
128
|
-
# DateTime
|
129
127
|
buff.no_break_append(separator).append(value.strftime('%Y-%m-%d %H:%M-%S.%L%:z'))
|
130
128
|
when Date
|
131
|
-
# DateTime
|
132
129
|
buff.no_break_append(separator).append(value.strftime('%Y-%m-%d'))
|
133
130
|
when Time
|
134
|
-
# DateTime
|
135
131
|
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
132
|
when Array, Set, Hash
|
140
|
-
# Array, Set, Hash
|
141
133
|
value_buff = to_string_enumerable(value, print_options)
|
142
134
|
buff.append_buffer(separator, value_buff)
|
143
135
|
else
|
144
136
|
value_buff = LogBuffer.new(@@config.maximum_data_output_width)
|
145
|
-
if !print_options.
|
137
|
+
if !print_options.reflection && has_to_s_method?(value)
|
146
138
|
# has to_s or inspect method
|
147
139
|
value_buff.append('to_s: ')
|
148
140
|
value_buff.no_break_append(value.to_s)
|
@@ -152,7 +144,7 @@ module DebugTrace
|
|
152
144
|
if @@reflected_objects.any? { |obj| value.equal?(obj) }
|
153
145
|
# cyclic reference
|
154
146
|
value_buff.no_break_append(@@config.cyclic_reference_string)
|
155
|
-
elsif @@reflected_objects.length > print_options.
|
147
|
+
elsif @@reflected_objects.length > print_options.reflection_limit
|
156
148
|
# over reflection level limitation
|
157
149
|
value_buff.no_break_append(@@config.limit_string)
|
158
150
|
else
|
@@ -470,10 +462,10 @@ module DebugTrace
|
|
470
462
|
|
471
463
|
@@DO_NOT_OUTPUT = 'Do not output'
|
472
464
|
|
473
|
-
def self.print(name, value = @@DO_NOT_OUTPUT,
|
465
|
+
def self.print(name, value = @@DO_NOT_OUTPUT, reflection: false,
|
474
466
|
minimum_output_count: -1, minimum_output_length: -1,
|
475
467
|
collection_limit: -1, bytes_limit: -1,
|
476
|
-
string_limit: -1,
|
468
|
+
string_limit: -1, reflection_limit: -1)
|
477
469
|
@@thread_mutex.synchronize do
|
478
470
|
print_start
|
479
471
|
return value unless @@config.enabled?
|
@@ -490,10 +482,10 @@ module DebugTrace
|
|
490
482
|
else
|
491
483
|
# with value
|
492
484
|
print_options = PrintOptions.new(
|
493
|
-
|
485
|
+
reflection,
|
494
486
|
minimum_output_count, minimum_output_length,
|
495
487
|
collection_limit, bytes_limit,
|
496
|
-
string_limit,
|
488
|
+
string_limit, reflection_limit
|
497
489
|
)
|
498
490
|
@@last_log_buff = to_string(name, value, print_options)
|
499
491
|
end
|