debugtrace 1.0.1 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e872094eb59159d108f2e52625b202800b7278dc17679fbae19e06d5a23d422
4
- data.tar.gz: bca0f74ed3a13386f01d77b1ae07b2b204c6eb3c93b55d48478ac35d0745436b
3
+ metadata.gz: fa74406233753b57eb94f0f05e67ec9e9818014ccaa6fda15a93ff65bd406be4
4
+ data.tar.gz: 131f249a1bddfd25c5be1d7c87a140c8b77540863ea8b84a6b9a5205f3bb57db
5
5
  SHA512:
6
- metadata.gz: fcaafba29d038f8f15cbb6cfbb9936065ee352a7d71441a832e72b20ac97f149c5752121f74776d0ecaf79e491a556542af18cbf4b524000cc73243a419b4478
7
- data.tar.gz: e56bf266a536877979e38a3492e192f270a38b4c92524f57b1991b4c3da8d15603f10cbefa3b9888d8711c642152ff3d6017a6003abcca3435c740208f8cbf52
6
+ metadata.gz: 1ff6920733cfc9e0f51d3fe0b532cb5389ca419cf6f950c3bd4083a6202e4673cd0eb93ba67df1aaca431562dc8a36c43c67572d20fc90e0e30b0a265f18ec3c
7
+ data.tar.gz: de378f10d17017256fa03c5fac2fa2709e9b0ee8775f79c7373139302baeb062584ea5534f43a3d74f4725e2ae448257aa69bd3ba6c245bd5e26a7c5b31650ba
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
- ## [Unreleased]
1
+ ## 1.1.0 - May 25, 2025
2
2
 
3
- ## [0.1.0] - 2022-12-10
3
+ ### Bug fixes
4
4
 
5
- - Initial release
5
+ * Fixed a bug where line breaks were not inserted between elements when outputting `Array`, `Hash`, and `Set` using the print method.
6
+
7
+ ### Specification changes
8
+
9
+ * Changed the following keyword argument names for the `print` method, and also changed the property names of the same names in `debugtrace.yml`.
10
+ * `output_size_limit` ← `collection_limit`
11
+ * `output_length_limit` ← `string_limit` and `bytes_limit` _(Unified)_
12
+
13
+ ## 1.0.1 - May 19, 2025
14
+
15
+ Fixed a bug that caused an error if the environment variable `DEBUGTRACE_CONFIG` was not set.
16
+
17
+ ## 1.0.0 - May 18, 2025
18
+
19
+ This is the initial release.
data/README.md CHANGED
@@ -140,8 +140,8 @@ DebugTrace module has the following methods.
140
140
  <small><i>The following arguments can be specified in debugtrace.yml (argument specification takes precedence)</i></small><br>
141
141
  <code>minimum_output_size</code>: The minimum number of elements to print for <code>Array</code>, <code>Hash</code> and <code>Set</code><br>
142
142
  <code>minimum_output_length</code>: The minimum length to print the length of the string<br>
143
- <code>collection_limit</code>: The limit on the number of elements output for <code>Map</code>, <code>Hash</code> and <code>Set</code><br>
144
- <code>string_limit</code>: The limit on the number of characters that can be output from a string<br>
143
+ <code>output_size_limit</code>: The limit on the number of elements output for <code>Map</code>, <code>Hash</code> and <code>Set</code><br>
144
+ <code>output_length_limit</code>: The limit on the number of characters that can be output from a string<br>
145
145
  <code>reflection_limit</code>: The limit of reflection nesting<br>
146
146
  </td>
147
147
  <td>the argument value if it is specified, otherwise <code>nil</code></td>
@@ -527,44 +527,30 @@ You can specify the following properties in debugtrace.yml.
527
527
  </td>
528
528
  </tr>
529
529
  <tr>
530
- <td><code>collection_limit</code></td>
530
+ <td><code>output_size_limit</code></td>
531
531
  <td>
532
532
  The limit on the number of elements output for <code>Array</code>, <code>Hash</code>, and <code>Set</code><br>
533
533
  <small><b>Example:</b></small>
534
534
  <ul>
535
- <code>collection_limit: 64</code>
535
+ <code>output_size_limit: 64</code>
536
536
  </ul>
537
537
  <small><b>Default Value:</b></small>
538
538
  <ul>
539
- <code>collection_limit: 128</code>
539
+ <code>output_size_limit: 128</code>
540
540
  </ul>
541
541
  </td>
542
542
  </tr>
543
543
  <tr>
544
- <td><code>string_limit</code></td>
544
+ <td><code>output_length_limit</code></td>
545
545
  <td>
546
- 文字列の出力文字数の制限値<br>
546
+ The limit on the number of characters that can be output from a string<br>
547
547
  <small><b>Example:</b></small>
548
548
  <ul>
549
- <code>string_limit: 64</code>
549
+ <code>output_length_limit: 64</code>
550
550
  </ul>
551
551
  <small><b>Default Value:</b></small>
552
552
  <ul>
553
- <code>string_limit: 256</code>
554
- </ul>
555
- </td>
556
- </tr>
557
- <tr>
558
- <td><code>bytes_limit</code></td>
559
- <td>
560
- The limit on the number of characters to be output a string as a byte array<br>
561
- <small><b>Example:</b></small>
562
- <ul>
563
- <code>bytes_limit: 64</code>
564
- </ul>
565
- <small><b>Default Value:</b></small>
566
- <ul>
567
- <code>bytes_limit: 256</code>
553
+ <code>output_length_limit: 256</code>
568
554
  </ul>
569
555
  </td>
570
556
  </tr>
@@ -584,7 +570,11 @@ You can specify the following properties in debugtrace.yml.
584
570
  </tr>
585
571
  </table>
586
572
 
587
- ### 6. License
573
+ ### 6. CHANGELOG
574
+
575
+ [CHANGELOG](CHANGELOG.md)
576
+
577
+ ### 7. License
588
578
 
589
579
  [MIT License(MIT)](LICENSE.txt)
590
580
 
data/README_ja.md CHANGED
@@ -138,8 +138,8 @@ DebugTraceモジュールには以下のメソッドがあります。
138
138
  <small><i>以降の引数は、debugtrace.ymlで指定可能 (引数指定が優先)</i></small><br>
139
139
  <code>minimum_output_size</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素数を出力する最小要素数<br>
140
140
  <code>minimum_output_length</code>: 文字列の長さを出力する最小の長さ<br>
141
- <code>collection_limit</code>: <code>Map</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値<br>
142
- <code>string_limit</code>: 文字列の出力文字数の制限値<br>
141
+ <code>output_size_limit</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値<br>
142
+ <code>output_length_limit</code>: 文字列の出力文字数の制限値<br>
143
143
  <code>reflection_limit</code>: リフレクションのネスト数の制限値<br>
144
144
  </td>
145
145
  <td>値の指定があれば引数値、なければ<code>nil</code></td>
@@ -525,44 +525,30 @@ debugtrace.ymlには以下のプロパティを指定できます。
525
525
  </td>
526
526
  </tr>
527
527
  <tr>
528
- <td><code>collection_limit</code></td>
528
+ <td><code>output_size_limit</code></td>
529
529
  <td>
530
530
  Array</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値<br>
531
531
  <small><b>設定例:</b></small>
532
532
  <ul>
533
- <code>collection_limit: 64</code>
533
+ <code>output_size_limit: 64</code>
534
534
  </ul>
535
535
  <small><b>初期値:</b></small>
536
536
  <ul>
537
- <code>collection_limit: 128</code>
537
+ <code>output_size_limit: 128</code>
538
538
  </ul>
539
539
  </td>
540
540
  </tr>
541
541
  <tr>
542
- <td><code>string_limit</code></td>
542
+ <td><code>output_length_limit</code></td>
543
543
  <td>
544
544
  文字列の出力文字数の制限値<br>
545
545
  <small><b>設定例:</b></small>
546
546
  <ul>
547
- <code>string_limit: 64</code>
547
+ <code>output_length_limit: 64</code>
548
548
  </ul>
549
549
  <small><b>初期値:</b></small>
550
550
  <ul>
551
- <code>string_limit: 256</code>
552
- </ul>
553
- </td>
554
- </tr>
555
- <tr>
556
- <td><code>bytes_limit</code></td>
557
- <td>
558
- 文字列をバイト配列として出力する場合のの出力数の制限値<br>
559
- <small><b>設定例:</b></small>
560
- <ul>
561
- <code>bytes_limit: 64</code>
562
- </ul>
563
- <small><b>初期値:</b></small>
564
- <ul>
565
- <code>bytes_limit: 256</code>
551
+ <code>output_length_limit: 256</code>
566
552
  </ul>
567
553
  </td>
568
554
  </tr>
@@ -582,7 +568,11 @@ debugtrace.ymlには以下のプロパティを指定できます。
582
568
  </tr>
583
569
  </table>
584
570
 
585
- ### 6. ライセンス
571
+ ### 6. 修正履歴
572
+
573
+ [修正履歴](CHANGELOG_ja.md)
574
+
575
+ ### 7. ライセンス
586
576
 
587
577
  [MIT ライセンス(MIT)](LICENSE.txt)
588
578
 
@@ -22,7 +22,6 @@ length_format: "(length=%d)"
22
22
  minimum_output_length: 6
23
23
  data_output_width: 40
24
24
  bytes_count_in_line: 32
25
- collection_limit: 64
26
- string_limit: 5
27
- bytes_limit: 64
25
+ output_size_limit: 64
26
+ output_length_limit: 5
28
27
  reflection_limit: 3
@@ -8,31 +8,30 @@ require_relative 'common'
8
8
  class Config
9
9
  attr_reader :config_path
10
10
  attr_reader :config
11
- attr_reader :logger_name
12
- attr_reader :log_path
13
- attr_reader :rubylogger_format
14
- attr_reader :log_datetime_format
15
- attr_reader :enter_format
16
- attr_reader :leave_format
17
- attr_reader :thread_boundary_format
18
- attr_reader :maximum_indents
19
- attr_reader :indent_string
20
- attr_reader :data_indent_string
21
- attr_reader :limit_string
22
- attr_reader :circular_reference_string
23
- attr_reader :varname_value_separator
24
- attr_reader :key_value_separator
25
- attr_reader :print_suffix_format
26
- attr_reader :size_format
27
- attr_reader :minimum_output_size
28
- attr_reader :length_format
29
- attr_reader :minimum_output_length
30
- attr_reader :data_output_width
31
- attr_reader :bytes_count_in_line
32
- attr_reader :collection_limit
33
- attr_reader :string_limit
34
- attr_reader :bytes_limit
35
- attr_reader :reflection_limit
11
+ attr_accessor :logger_name
12
+ attr_accessor :log_path
13
+ attr_accessor :rubylogger_format
14
+ attr_accessor :log_datetime_format
15
+ attr_accessor :enter_format
16
+ attr_accessor :leave_format
17
+ attr_accessor :thread_boundary_format
18
+ attr_accessor :maximum_indents
19
+ attr_accessor :indent_string
20
+ attr_accessor :data_indent_string
21
+ attr_accessor :limit_string
22
+ attr_accessor :circular_reference_string
23
+ attr_accessor :varname_value_separator
24
+ attr_accessor :key_value_separator
25
+ attr_accessor :print_suffix_format
26
+ attr_accessor :size_format
27
+ attr_accessor :minimum_output_size
28
+ attr_accessor :length_format
29
+ attr_accessor :minimum_output_length
30
+ attr_accessor :data_output_width
31
+ attr_accessor :bytes_count_in_line
32
+ attr_accessor :output_size_limit
33
+ attr_accessor :output_length_limit
34
+ attr_accessor :reflection_limit
36
35
 
37
36
  # Initializes with a yml file in the config_path.
38
37
  #
@@ -45,32 +44,31 @@ class Config
45
44
  @config_path = '<No config file>'
46
45
  @config = nil
47
46
  end
48
- @logger_name = get_value 'logger' , 'stderr'
49
- @log_path = get_value 'log_path' , 'debugtrace.log'
50
- @rubylogger_format = get_value 'rubylogger_format' , "%2$s %1$s %4$s\n"
51
- @log_datetime_format = get_value 'log_datetime_format' , '%Y-%m-%d %H:%M:%S.%L%:z'
52
- @enabled = get_value 'enabled' , true
53
- @enter_format = get_value 'enter_format' , 'Enter %1$s (%2$s:%3$d) <- %4$s (%5$s:%6$d)'
54
- @leave_format = get_value 'leave_format' , 'Leave %1$s (%2$s:%3$d) duration: %4$.3f ms'
55
- @thread_boundary_format = get_value 'thread_boundary_format' , '______________________________ %1$s #%2$d ______________________________'
56
- @maximum_indents = get_value 'maximum_indents' , 32
57
- @indent_string = get_value 'indent_string' , '| '
58
- @data_indent_string = get_value 'data_indent_string' , ' '
59
- @limit_string = get_value 'limit_string' , '...'
60
- @circular_reference_string = get_value 'circular_reference_string' , '*** Circular Reference ***'
61
- @varname_value_separator = get_value 'varname_value_separator' , ' = '
62
- @key_value_separator = get_value 'key_value_separator' , ': '
63
- @print_suffix_format = get_value 'print_suffix_format' , ' (%2$s:%3$d)'
64
- @size_format = get_value 'size_format' , '(size:%d)'
65
- @minimum_output_size = get_value 'minimum_output_size' , 256
66
- @length_format = get_value 'length_format' , '(length:%d)'
67
- @minimum_output_length = get_value 'minimum_output_length' , 256
68
- @data_output_width = get_value 'data_output_width' , 70
69
- @bytes_count_in_line = get_value 'bytes_count_in_line' , 16
70
- @collection_limit = get_value 'collection_limit' , 128
71
- @string_limit = get_value 'string_limit' , 256
72
- @bytes_limit = get_value 'bytes_limit' , 256
73
- @reflection_limit = get_value 'reflection_limit' , 4
47
+ @logger_name = get_value 'logger' , 'stderr'
48
+ @log_path = get_value 'log_path' , 'debugtrace.log'
49
+ @rubylogger_format = get_value 'rubylogger_format' , "%2$s %1$s %4$s\n"
50
+ @log_datetime_format = get_value 'log_datetime_format' , '%Y-%m-%d %H:%M:%S.%L%:z'
51
+ @enabled = get_value 'enabled' , true
52
+ @enter_format = get_value 'enter_format' , 'Enter %1$s (%2$s:%3$d) <- %4$s (%5$s:%6$d)'
53
+ @leave_format = get_value 'leave_format' , 'Leave %1$s (%2$s:%3$d) duration: %4$.3f ms'
54
+ @thread_boundary_format = get_value 'thread_boundary_format' , '______________________________ %1$s #%2$d ______________________________'
55
+ @maximum_indents = get_value 'maximum_indents' , 32
56
+ @indent_string = get_value 'indent_string' , '| '
57
+ @data_indent_string = get_value 'data_indent_string' , ' '
58
+ @limit_string = get_value 'limit_string' , '...'
59
+ @circular_reference_string = get_value 'circular_reference_string', '*** Circular Reference ***'
60
+ @varname_value_separator = get_value 'varname_value_separator' , ' = '
61
+ @key_value_separator = get_value 'key_value_separator' , ': '
62
+ @print_suffix_format = get_value 'print_suffix_format' , ' (%2$s:%3$d)'
63
+ @size_format = get_value 'size_format' , '(size:%d)'
64
+ @minimum_output_size = get_value 'minimum_output_size' , 256
65
+ @length_format = get_value 'length_format' , '(length:%d)'
66
+ @minimum_output_length = get_value 'minimum_output_length' , 256
67
+ @data_output_width = get_value 'data_output_width' , 70
68
+ @bytes_count_in_line = get_value 'bytes_count_in_line' , 16
69
+ @output_size_limit = get_value 'output_size_limit' , 128
70
+ @output_length_limit = get_value 'output_length_limit' , 256
71
+ @reflection_limit = get_value 'reflection_limit' , 4
74
72
  end
75
73
 
76
74
  # Returns true if logging is enabled, false otherwise.
@@ -93,7 +93,7 @@ class LogBuffer
93
93
  index = 0
94
94
  for line in buff.lines
95
95
  line_feed if index > 0
96
- append(line.log, line.nest_level, true)
96
+ append(line.log, line.nest_level)
97
97
  index += 1
98
98
  end
99
99
  return self
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
- # (C) 2025 Masato Kokubo
3
2
 
4
3
  module DebugTrace
5
- VERSION = '1.0.1'
4
+ VERSION = '1.1.0'
6
5
  end
data/lib/debugtrace.rb CHANGED
@@ -86,32 +86,29 @@ module DebugTrace
86
86
  # Contains options to pass to the print method.
87
87
  class PrintOptions
88
88
  attr_reader :reflection, :minimum_output_size, :minimum_output_length,
89
- :collection_limit, :bytes_limit, :string_limit, :reflection_limit
89
+ :output_size_limit, :output_length_limit, :reflection_limit
90
90
 
91
91
  # Initializes this object.
92
92
  #
93
93
  # @param reflection [TrueClass, FalseClass] use reflection if true
94
94
  # @param minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
95
95
  # @param minimum_output_length [Integer] the minimum value to output the length of String and byte array (overrides debugtarace.yml value)
96
- # @param collection_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
97
- # @param bytes_limit [Integer] the limit value of elements for bytes and bytearray to output (overrides debugtarace.yml value)
98
- # @param string_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
96
+ # @param output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
97
+ # @param output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
99
98
  # @param reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
100
99
  def initialize(
101
100
  reflection,
102
101
  minimum_output_size,
103
102
  minimum_output_length,
104
- collection_limit,
105
- bytes_limit,
106
- string_limit,
103
+ output_size_limit,
104
+ output_length_limit,
107
105
  reflection_limit
108
106
  )
109
107
  @reflection = reflection
110
108
  @minimum_output_size = minimum_output_size == -1 ? DebugTrace.config.minimum_output_size : minimum_output_size
111
109
  @minimum_output_length = minimum_output_length == -1 ? DebugTrace.config.minimum_output_length : minimum_output_length
112
- @collection_limit = collection_limit == -1 ? DebugTrace.config.collection_limit : collection_limit
113
- @bytes_limit = bytes_limit == -1 ? DebugTrace.config.bytes_limit : bytes_limit
114
- @string_limit = string_limit == -1 ? DebugTrace.config.string_limit : string_limit
110
+ @output_size_limit = output_size_limit == -1 ? DebugTrace.config.output_size_limit : output_size_limit
111
+ @output_length_limit = output_length_limit == -1 ? DebugTrace.config.output_length_limit : output_length_limit
115
112
  @reflection_limit = reflection_limit == -1 ? DebugTrace.config.reflection_limit : reflection_limit
116
113
  end
117
114
  end
@@ -228,7 +225,7 @@ module DebugTrace
228
225
 
229
226
  count = 1
230
227
  value.each_char do |char|
231
- if count > print_options.string_limit
228
+ if count > print_options.output_length_limit
232
229
  single_quote_buff.no_break_append(@@config.limit_string)
233
230
  double_quote_buff.no_break_append(@@config.limit_string)
234
231
  break
@@ -302,7 +299,7 @@ module DebugTrace
302
299
  buff.line_feed
303
300
  chars = ''
304
301
  end
305
- if count >= print_options.bytes_limit
302
+ if count >= print_options.output_length_limit
306
303
  buff.no_break_append(@@config.limit_string)
307
304
  break
308
305
  end
@@ -414,11 +411,11 @@ module DebugTrace
414
411
  close_char = ']'
415
412
 
416
413
  if values.is_a?(Hash)
417
- # Array
414
+ # Hash
418
415
  open_char = '{'
419
416
  close_char = '}'
420
417
  elsif values.is_a?(Set)
421
- # Sete
418
+ # Set
422
419
  open_char = 'Set['
423
420
  close_char = ']'
424
421
  end
@@ -461,7 +458,7 @@ module DebugTrace
461
458
  values.each do |element|
462
459
  buff.no_break_append(', ') if index > 0
463
460
 
464
- if index >= print_options.collection_limit
461
+ if index >= print_options.output_size_limit
465
462
  buff.append(@@config.limit_string)
466
463
  break
467
464
  end
@@ -540,15 +537,12 @@ module DebugTrace
540
537
  # @option reflection [TrueClass, FalseClass] use reflection if true
541
538
  # @option minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
542
539
  # @option minimum_output_length [Integer] the minimum value to output the length of String and byte array (overrides debugtarace.yml value)
543
- # @option collection_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
544
- # @option bytes_limit [Integer] the limit value of elements for bytes and bytearray to output (overrides debugtarace.yml value)
545
- # @option string_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
540
+ # @option output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
541
+ # @option output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
546
542
  # @option reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
547
543
  def self.print(name, value = @@DO_NOT_OUTPUT,
548
- reflection: false,
549
- minimum_output_size: -1, minimum_output_length: -1,
550
- collection_limit: -1, bytes_limit: -1,
551
- string_limit: -1, reflection_limit: -1)
544
+ reflection: false, minimum_output_size: -1, minimum_output_length: -1,
545
+ output_size_limit: -1, output_length_limit: -1, reflection_limit: -1)
552
546
  @@thread_mutex.synchronize do
553
547
  print_start
554
548
  return value unless @@config.enabled?
@@ -565,10 +559,8 @@ module DebugTrace
565
559
  else
566
560
  # with value
567
561
  print_options = PrintOptions.new(
568
- reflection,
569
- minimum_output_size, minimum_output_length,
570
- collection_limit, bytes_limit,
571
- string_limit, reflection_limit
562
+ reflection, minimum_output_size, minimum_output_length,
563
+ output_size_limit, output_length_limit, reflection_limit
572
564
  )
573
565
  @@last_log_buff = to_string(name, value, print_options)
574
566
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: debugtrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masato Kokubo