debugtrace 1.0.1 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e872094eb59159d108f2e52625b202800b7278dc17679fbae19e06d5a23d422
4
- data.tar.gz: bca0f74ed3a13386f01d77b1ae07b2b204c6eb3c93b55d48478ac35d0745436b
3
+ metadata.gz: 329e4c78cb0dd2a7778ec83d17c6b8b6a98bddcb27360322fa757d9c0779fd04
4
+ data.tar.gz: f1b7c56f4c029320a869c71e84babbf521f1b43dae89be907bca1a8e00f0dda5
5
5
  SHA512:
6
- metadata.gz: fcaafba29d038f8f15cbb6cfbb9936065ee352a7d71441a832e72b20ac97f149c5752121f74776d0ecaf79e491a556542af18cbf4b524000cc73243a419b4478
7
- data.tar.gz: e56bf266a536877979e38a3492e192f270a38b4c92524f57b1991b4c3da8d15603f10cbefa3b9888d8711c642152ff3d6017a6003abcca3435c740208f8cbf52
6
+ metadata.gz: 72de200654893939ec841d1c70ba56be2f028b2afed076fbc649ccdc07b67a8a71705719e97e7bd5d3379143c43be6f4ec00c6c3f9e5308dec6132ff5a963957
7
+ data.tar.gz: 1159e8da5fc15885699615004d0ef361317f748281c7e90b284119adf64dcc6835578959cae095aed2640997ddb4be226437ca2049e5041c0911e2096dc5e970
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
- ## [Unreleased]
1
+ ## 1.1.1 - July 1, 2025
2
2
 
3
- ## [0.1.0] - 2022-12-10
3
+ ### Bug fixes
4
+ * Fixed a bug that caused exceptions to be thrown by the `enter`, `leave` and `print` methods depending on the conditions.
4
5
 
5
- - Initial release
6
+ ## 1.1.0 - May 25, 2025
7
+
8
+ ### Bug fixes
9
+
10
+ * Fixed a bug where line breaks were not inserted between elements when outputting `Array`, `Hash`, and `Set` using the print method.
11
+
12
+ ### Specification changes
13
+
14
+ * Changed the following keyword argument names for the `print` method, and also changed the property names of the same names in `debugtrace.yml`.
15
+ * `output_size_limit` ← `collection_limit`
16
+ * `output_length_limit` ← `string_limit` and `bytes_limit` _(Unified)_
17
+
18
+ ## 1.0.1 - May 19, 2025
19
+
20
+ Fixed a bug that caused an error if the environment variable `DEBUGTRACE_CONFIG` was not set.
21
+
22
+ ## 1.0.0 - May 18, 2025
23
+
24
+ This is the initial release.
data/CHANGELOG_ja.md ADDED
@@ -0,0 +1,24 @@
1
+ ## 1.1.1 - 2025/7/1
2
+
3
+ #### バグ修正
4
+ * 条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正。
5
+
6
+ ## 1.1.0 - 2025/5/25
7
+
8
+ #### バグ修正
9
+
10
+ * `print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間での改行が行われないバグの修正。
11
+
12
+ #### 仕様変更
13
+
14
+ * `print`メソッドの以下のキーワード引数名を変更、また`debugtrace.yml`の同名のプロパティ名も変更
15
+ * `output_size_limit` ← `collection_limit`
16
+ * `output_length_limit` ← `string_limit` および `bytes_limit` _(統一)_
17
+
18
+ ## 1.0.1 - 2025/5/19
19
+
20
+ 環境変数 `DEBUGTRACE_CONFIG` が設定されていない場合にエラーが発生するバグを修正
21
+
22
+ ## 1.0.0 - 2025/5/18
23
+
24
+ 最初のリリース
data/README.md CHANGED
@@ -63,47 +63,46 @@ def func2
63
63
  Contact.new(1, 'Akane' , 'Apple', Date.new(1991, 2, 3)),
64
64
  Contact.new(2, 'Yukari', 'Apple', Date.new(1992, 3, 4))
65
65
  ]
66
- DebugTrace.print('contacts', contacts)
67
- DebugTrace.leave
66
+ DebugTrace.leave(contacts)
68
67
  end
69
68
 
70
69
  def func1
71
70
  DebugTrace.enter
72
71
  DebugTrace.print('Hello, World!')
73
- func2
74
- DebugTrace.leave
72
+ contacts = func2
73
+ DebugTrace.leave(contacts)
75
74
  end
76
75
 
77
76
  func1
78
77
  ```
79
78
 
80
79
  ```log
81
- 2025-05-17 20:38:04.084+09:00 DebugTrace-rb 1.0.0 on Ruby 3.4.4
82
- 2025-05-17 20:38:04.084+09:00 config file: <No config file>
83
- 2025-05-17 20:38:04.084+09:00 logger: StdErrLogger
84
- 2025-05-17 20:38:04.084+09:00
85
- 2025-05-17 20:38:04.084+09:00 ______________________________ #72 ______________________________
86
- 2025-05-17 20:38:04.084+09:00
87
- 2025-05-17 20:38:04.085+09:00 Enter func1 (readme-example.rb:30) <- <main> (readme-example.rb:36)
88
- 2025-05-17 20:38:04.085+09:00 | Hello, World! (readme-example.rb:31)
89
- 2025-05-17 20:38:04.085+09:00 | Enter func2 (readme-example.rb:20) <- func1 (readme-example.rb:32)
90
- 2025-05-17 20:38:04.085+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:22)
91
- 2025-05-17 20:38:04.085+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.015 ms
92
- 2025-05-17 20:38:04.085+09:00 | |
93
- 2025-05-17 20:38:04.085+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:23)
94
- 2025-05-17 20:38:04.085+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.010 ms
95
- 2025-05-17 20:38:04.085+09:00 | |
96
- 2025-05-17 20:38:04.085+09:00 | | contacts = [
97
- 2025-05-17 20:38:04.085+09:00 | | Contact{
98
- 2025-05-17 20:38:04.085+09:00 | | @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
99
- 2025-05-17 20:38:04.085+09:00 | | },
100
- 2025-05-17 20:38:04.085+09:00 | | Contact{
101
- 2025-05-17 20:38:04.085+09:00 | | @id: 2, @firstName: 'Yukari', @lastName: 'Apple', @birthday: 1992-03-04
102
- 2025-05-17 20:38:04.085+09:00 | | }
103
- 2025-05-17 20:38:04.085+09:00 | | ] (readme-example.rb:25)
104
- 2025-05-17 20:38:04.085+09:00 | |
105
- 2025-05-17 20:38:04.085+09:00 | Leave func2 (readme-example.rb:26) duration: 0.789 ms
106
- 2025-05-17 20:38:04.085+09:00 Leave func1 (readme-example.rb:33) duration: 0.937 ms
80
+ 2025-07-01 19:12:34.756+09:00 DebugTrace-rb 1.1.1 on Ruby 3.4.4
81
+ 2025-07-01 19:12:34.756+09:00 config file: <No config file>
82
+ 2025-07-01 19:12:34.756+09:00 logger: StdErrLogger
83
+ 2025-07-01 19:12:34.756+09:00
84
+ 2025-07-01 19:12:34.756+09:00 ______________________________ #72 ______________________________
85
+ 2025-07-01 19:12:34.756+09:00
86
+ 2025-07-01 19:12:34.756+09:00 Enter func1 (readme-example.rb:29) <- <main> (readme-example.rb:35)
87
+ 2025-07-01 19:12:34.756+09:00 | Hello, World! (readme-example.rb:30)
88
+ 2025-07-01 19:12:34.756+09:00 | Enter func2 (readme-example.rb:20) <- func1 (readme-example.rb:31)
89
+ 2025-07-01 19:12:34.756+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:22)
90
+ 2025-07-01 19:12:34.756+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.012 ms
91
+ 2025-07-01 19:12:34.756+09:00 | |
92
+ 2025-07-01 19:12:34.756+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:23)
93
+ 2025-07-01 19:12:34.756+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.008 ms
94
+ 2025-07-01 19:12:34.756+09:00 | Leave func2 (readme-example.rb:25) duration: 0.236 ms
95
+ 2025-07-01 19:12:34.757+09:00 Leave func1 (readme-example.rb:32) duration: 0.365 ms
96
+ 2025-07-01 19:12:34.757+09:00
97
+ 2025-07-01 19:12:34.757+09:00 contacts = [
98
+ 2025-07-01 19:12:34.757+09:00 Contact{
99
+ 2025-07-01 19:12:34.757+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
100
+ 2025-07-01 19:12:34.757+09:00 },
101
+ 2025-07-01 19:12:34.757+09:00 Contact{
102
+ 2025-07-01 19:12:34.757+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
103
+ 2025-07-01 19:12:34.757+09:00 @birthday: 1992-03-04
104
+ 2025-07-01 19:12:34.757+09:00 }
105
+ 2025-07-01 19:12:34.757+09:00 ] (readme-example.rb:36)
107
106
  ```
108
107
 
109
108
  ### 4. List of methods
@@ -140,8 +139,8 @@ DebugTrace module has the following methods.
140
139
  <small><i>The following arguments can be specified in debugtrace.yml (argument specification takes precedence)</i></small><br>
141
140
  <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
141
  <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>
142
+ <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>
143
+ <code>output_length_limit</code>: The limit on the number of characters that can be output from a string<br>
145
144
  <code>reflection_limit</code>: The limit of reflection nesting<br>
146
145
  </td>
147
146
  <td>the argument value if it is specified, otherwise <code>nil</code></td>
@@ -527,44 +526,30 @@ You can specify the following properties in debugtrace.yml.
527
526
  </td>
528
527
  </tr>
529
528
  <tr>
530
- <td><code>collection_limit</code></td>
529
+ <td><code>output_size_limit</code></td>
531
530
  <td>
532
531
  The limit on the number of elements output for <code>Array</code>, <code>Hash</code>, and <code>Set</code><br>
533
532
  <small><b>Example:</b></small>
534
533
  <ul>
535
- <code>collection_limit: 64</code>
534
+ <code>output_size_limit: 64</code>
536
535
  </ul>
537
536
  <small><b>Default Value:</b></small>
538
537
  <ul>
539
- <code>collection_limit: 128</code>
538
+ <code>output_size_limit: 128</code>
540
539
  </ul>
541
540
  </td>
542
541
  </tr>
543
542
  <tr>
544
- <td><code>string_limit</code></td>
543
+ <td><code>output_length_limit</code></td>
545
544
  <td>
546
- 文字列の出力文字数の制限値<br>
545
+ The limit on the number of characters that can be output from a string<br>
547
546
  <small><b>Example:</b></small>
548
547
  <ul>
549
- <code>string_limit: 64</code>
548
+ <code>output_length_limit: 64</code>
550
549
  </ul>
551
550
  <small><b>Default Value:</b></small>
552
551
  <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>
552
+ <code>output_length_limit: 256</code>
568
553
  </ul>
569
554
  </td>
570
555
  </tr>
@@ -584,9 +569,13 @@ You can specify the following properties in debugtrace.yml.
584
569
  </tr>
585
570
  </table>
586
571
 
587
- ### 6. License
572
+ ### 6. CHANGELOG
573
+
574
+ [CHANGELOG](CHANGELOG.md)
575
+
576
+ ### 7. License
588
577
 
589
578
  [MIT License(MIT)](LICENSE.txt)
590
579
 
591
- _(C) 2025 Masato Kokubo_
580
+ _&copy; 2025 Masato Kokubo_
592
581
 
data/README_ja.md CHANGED
@@ -5,7 +5,7 @@
5
5
  **DebugTrace-rb** は、Rubyのデバッグ時にトレースログを出力するライブラリで、 Ruby 3.1.0以降で利用できます。
6
6
  メソッドの開始と終了箇所に`DebugTrace.enter`および`DebugTrace.leave` を埋め込む事で、開発中のRubyプログラムの実行状況を出力する事ができます。
7
7
 
8
- ## 1. 特徴
8
+ ### 1. 特徴
9
9
 
10
10
  * 呼び出し元のメソッド名、ソースファイル名および行番号を自動的に出力。
11
11
  * メソッドやオブジェクトのネストで、ログを自動的にインデント 。
@@ -13,7 +13,7 @@
13
13
  * リフレクションを使用してオブジェクト内容の出力が可能。
14
14
  * `debugtrace.yml`ファイルの設定で、出力内容のカスタマイズが可能。
15
15
 
16
- ## 2. インストール
16
+ ### 2. インストール
17
17
 
18
18
  次のコマンドを実行して、gemをインストールし、アプリケーションのGemfileに追加します。
19
19
 
@@ -27,7 +27,7 @@ $ bundle add debugtrace
27
27
  $ gem install debugtrace
28
28
  ```
29
29
 
30
- ## 3. 使用方法
30
+ ### 3. 使用方法
31
31
 
32
32
  デバッグ対象および関連するメソッドに対して以下を行います。
33
33
 
@@ -40,7 +40,8 @@ $ gem install debugtrace
40
40
  ```ruby
41
41
  # frozen_string_literal: true
42
42
  # readme-example.rb
43
- require 'debugtrace'
43
+ #require 'debugtrace'
44
+ require_relative '../lib/debugtrace'
44
45
 
45
46
  class Contact
46
47
  attr_reader :id, :firstName, :lastName, :birthday
@@ -61,47 +62,47 @@ def func2
61
62
  Contact.new(1, 'Akane' , 'Apple', Date.new(1991, 2, 3)),
62
63
  Contact.new(2, 'Yukari', 'Apple', Date.new(1992, 3, 4))
63
64
  ]
64
- DebugTrace.print('contacts', contacts)
65
- DebugTrace.leave
65
+ DebugTrace.leave(contacts)
66
66
  end
67
67
 
68
68
  def func1
69
69
  DebugTrace.enter
70
70
  DebugTrace.print('Hello, World!')
71
- func2
72
- DebugTrace.leave
71
+ contacts = func2
72
+ DebugTrace.leave(contacts)
73
73
  end
74
74
 
75
- func1
75
+ contacts = func1
76
+ DebugTrace.print('contacts', contacts)
76
77
  ```
77
78
 
78
79
  ```log
79
- 2025-05-17 20:38:04.084+09:00 DebugTrace-rb 1.0.0 on Ruby 3.4.4
80
- 2025-05-17 20:38:04.084+09:00 config file: <No config file>
81
- 2025-05-17 20:38:04.084+09:00 logger: StdErrLogger
82
- 2025-05-17 20:38:04.084+09:00
83
- 2025-05-17 20:38:04.084+09:00 ______________________________ #72 ______________________________
84
- 2025-05-17 20:38:04.084+09:00
85
- 2025-05-17 20:38:04.085+09:00 Enter func1 (readme-example.rb:30) <- <main> (readme-example.rb:36)
86
- 2025-05-17 20:38:04.085+09:00 | Hello, World! (readme-example.rb:31)
87
- 2025-05-17 20:38:04.085+09:00 | Enter func2 (readme-example.rb:20) <- func1 (readme-example.rb:32)
88
- 2025-05-17 20:38:04.085+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:22)
89
- 2025-05-17 20:38:04.085+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.015 ms
90
- 2025-05-17 20:38:04.085+09:00 | |
91
- 2025-05-17 20:38:04.085+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:23)
92
- 2025-05-17 20:38:04.085+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.010 ms
93
- 2025-05-17 20:38:04.085+09:00 | |
94
- 2025-05-17 20:38:04.085+09:00 | | contacts = [
95
- 2025-05-17 20:38:04.085+09:00 | | Contact{
96
- 2025-05-17 20:38:04.085+09:00 | | @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
97
- 2025-05-17 20:38:04.085+09:00 | | },
98
- 2025-05-17 20:38:04.085+09:00 | | Contact{
99
- 2025-05-17 20:38:04.085+09:00 | | @id: 2, @firstName: 'Yukari', @lastName: 'Apple', @birthday: 1992-03-04
100
- 2025-05-17 20:38:04.085+09:00 | | }
101
- 2025-05-17 20:38:04.085+09:00 | | ] (readme-example.rb:25)
102
- 2025-05-17 20:38:04.085+09:00 | |
103
- 2025-05-17 20:38:04.085+09:00 | Leave func2 (readme-example.rb:26) duration: 0.789 ms
104
- 2025-05-17 20:38:04.085+09:00 Leave func1 (readme-example.rb:33) duration: 0.937 ms
80
+ 2025-07-01 19:12:34.756+09:00 DebugTrace-rb 1.1.1 on Ruby 3.4.4
81
+ 2025-07-01 19:12:34.756+09:00 config file: <No config file>
82
+ 2025-07-01 19:12:34.756+09:00 logger: StdErrLogger
83
+ 2025-07-01 19:12:34.756+09:00
84
+ 2025-07-01 19:12:34.756+09:00 ______________________________ #72 ______________________________
85
+ 2025-07-01 19:12:34.756+09:00
86
+ 2025-07-01 19:12:34.756+09:00 Enter func1 (readme-example.rb:29) <- <main> (readme-example.rb:35)
87
+ 2025-07-01 19:12:34.756+09:00 | Hello, World! (readme-example.rb:30)
88
+ 2025-07-01 19:12:34.756+09:00 | Enter func2 (readme-example.rb:20) <- func1 (readme-example.rb:31)
89
+ 2025-07-01 19:12:34.756+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:22)
90
+ 2025-07-01 19:12:34.756+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.012 ms
91
+ 2025-07-01 19:12:34.756+09:00 | |
92
+ 2025-07-01 19:12:34.756+09:00 | | Enter initialize (readme-example.rb:10) <- new (readme-example.rb:23)
93
+ 2025-07-01 19:12:34.756+09:00 | | Leave initialize (readme-example.rb:15) duration: 0.008 ms
94
+ 2025-07-01 19:12:34.756+09:00 | Leave func2 (readme-example.rb:25) duration: 0.236 ms
95
+ 2025-07-01 19:12:34.757+09:00 Leave func1 (readme-example.rb:32) duration: 0.365 ms
96
+ 2025-07-01 19:12:34.757+09:00
97
+ 2025-07-01 19:12:34.757+09:00 contacts = [
98
+ 2025-07-01 19:12:34.757+09:00 Contact{
99
+ 2025-07-01 19:12:34.757+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
100
+ 2025-07-01 19:12:34.757+09:00 },
101
+ 2025-07-01 19:12:34.757+09:00 Contact{
102
+ 2025-07-01 19:12:34.757+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
103
+ 2025-07-01 19:12:34.757+09:00 @birthday: 1992-03-04
104
+ 2025-07-01 19:12:34.757+09:00 }
105
+ 2025-07-01 19:12:34.757+09:00 ] (readme-example.rb:36)
105
106
  ```
106
107
 
107
108
  ### 4. メソッド一覧
@@ -138,8 +139,8 @@ DebugTraceモジュールには以下のメソッドがあります。
138
139
  <small><i>以降の引数は、debugtrace.ymlで指定可能 (引数指定が優先)</i></small><br>
139
140
  <code>minimum_output_size</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素数を出力する最小要素数<br>
140
141
  <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>
142
+ <code>output_size_limit</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値<br>
143
+ <code>output_length_limit</code>: 文字列の出力文字数の制限値<br>
143
144
  <code>reflection_limit</code>: リフレクションのネスト数の制限値<br>
144
145
  </td>
145
146
  <td>値の指定があれば引数値、なければ<code>nil</code></td>
@@ -525,44 +526,30 @@ debugtrace.ymlには以下のプロパティを指定できます。
525
526
  </td>
526
527
  </tr>
527
528
  <tr>
528
- <td><code>collection_limit</code></td>
529
+ <td><code>output_size_limit</code></td>
529
530
  <td>
530
531
  Array</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値<br>
531
532
  <small><b>設定例:</b></small>
532
533
  <ul>
533
- <code>collection_limit: 64</code>
534
+ <code>output_size_limit: 64</code>
534
535
  </ul>
535
536
  <small><b>初期値:</b></small>
536
537
  <ul>
537
- <code>collection_limit: 128</code>
538
+ <code>output_size_limit: 128</code>
538
539
  </ul>
539
540
  </td>
540
541
  </tr>
541
542
  <tr>
542
- <td><code>string_limit</code></td>
543
+ <td><code>output_length_limit</code></td>
543
544
  <td>
544
545
  文字列の出力文字数の制限値<br>
545
546
  <small><b>設定例:</b></small>
546
547
  <ul>
547
- <code>string_limit: 64</code>
548
+ <code>output_length_limit: 64</code>
548
549
  </ul>
549
550
  <small><b>初期値:</b></small>
550
551
  <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>
552
+ <code>output_length_limit: 256</code>
566
553
  </ul>
567
554
  </td>
568
555
  </tr>
@@ -582,9 +569,13 @@ debugtrace.ymlには以下のプロパティを指定できます。
582
569
  </tr>
583
570
  </table>
584
571
 
585
- ### 6. ライセンス
572
+ ### 6. 修正履歴
573
+
574
+ [修正履歴](CHANGELOG_ja.md)
575
+
576
+ ### 7. ライセンス
586
577
 
587
578
  [MIT ライセンス(MIT)](LICENSE.txt)
588
579
 
589
- _(C) 2025 Masato Kokubo_
580
+ _&copy; 2025 Masato Kokubo_
590
581
 
@@ -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
@@ -22,15 +22,15 @@ def func2
22
22
  Contact.new(1, 'Akane' , 'Apple', Date.new(1991, 2, 3)),
23
23
  Contact.new(2, 'Yukari', 'Apple', Date.new(1992, 3, 4))
24
24
  ]
25
- DebugTrace.print('contacts', contacts)
26
- DebugTrace.leave
25
+ DebugTrace.leave(contacts)
27
26
  end
28
27
 
29
28
  def func1
30
29
  DebugTrace.enter
31
30
  DebugTrace.print('Hello, World!')
32
- func2
33
- DebugTrace.leave
31
+ contacts = func2
32
+ DebugTrace.leave(contacts)
34
33
  end
35
34
 
36
- func1
35
+ contacts = func1
36
+ DebugTrace.print('contacts', contacts)
@@ -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.
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+ # location.rb
3
+ # (C) 2025 Masato Kokubo
4
+
5
+ # Contains source location information.
6
+ class Location
7
+ attr_reader :name
8
+ attr_reader :filename
9
+ attr_reader :lineno
10
+
11
+ # Initializes this object.
12
+ #
13
+ # @param caller_location [Thread::Backtrace::Location] the caller location
14
+ def initialize(caller_location)
15
+ if caller_location == nil
16
+ @name = 'unknown'
17
+ @filename = 'unknown'
18
+ @lineno = 0
19
+ else
20
+ @name = caller_location.base_label
21
+ path = caller_location.absolute_path || caller_location.path || 'unknown'
22
+ @filename = File.basename(path)
23
+ @lineno = caller_location.lineno
24
+ end
25
+ end
26
+
27
+ # Returns a string representation of this object.
28
+ #
29
+ # @return [String] A string representation of this object
30
+ def to_s()
31
+ return "(Location){name: #{@name}, filename: #{@filename}, lineno: #{@lineno}"
32
+ end
33
+ end
@@ -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.1'
6
5
  end
data/lib/debugtrace.rb CHANGED
@@ -9,6 +9,7 @@ require 'date'
9
9
  require_relative 'debugtrace/version'
10
10
  require_relative 'debugtrace/common'
11
11
  require_relative 'debugtrace/config'
12
+ require_relative 'debugtrace/location'
12
13
  require_relative 'debugtrace/log_buffer'
13
14
  require_relative 'debugtrace/loggers'
14
15
  require_relative 'debugtrace/state'
@@ -86,32 +87,29 @@ module DebugTrace
86
87
  # Contains options to pass to the print method.
87
88
  class PrintOptions
88
89
  attr_reader :reflection, :minimum_output_size, :minimum_output_length,
89
- :collection_limit, :bytes_limit, :string_limit, :reflection_limit
90
+ :output_size_limit, :output_length_limit, :reflection_limit
90
91
 
91
92
  # Initializes this object.
92
93
  #
93
94
  # @param reflection [TrueClass, FalseClass] use reflection if true
94
95
  # @param minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
95
96
  # @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)
97
+ # @param output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
98
+ # @param output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
99
99
  # @param reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
100
100
  def initialize(
101
101
  reflection,
102
102
  minimum_output_size,
103
103
  minimum_output_length,
104
- collection_limit,
105
- bytes_limit,
106
- string_limit,
104
+ output_size_limit,
105
+ output_length_limit,
107
106
  reflection_limit
108
107
  )
109
108
  @reflection = reflection
110
109
  @minimum_output_size = minimum_output_size == -1 ? DebugTrace.config.minimum_output_size : minimum_output_size
111
110
  @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
111
+ @output_size_limit = output_size_limit == -1 ? DebugTrace.config.output_size_limit : output_size_limit
112
+ @output_length_limit = output_length_limit == -1 ? DebugTrace.config.output_length_limit : output_length_limit
115
113
  @reflection_limit = reflection_limit == -1 ? DebugTrace.config.reflection_limit : reflection_limit
116
114
  end
117
115
  end
@@ -228,7 +226,7 @@ module DebugTrace
228
226
 
229
227
  count = 1
230
228
  value.each_char do |char|
231
- if count > print_options.string_limit
229
+ if count > print_options.output_length_limit
232
230
  single_quote_buff.no_break_append(@@config.limit_string)
233
231
  double_quote_buff.no_break_append(@@config.limit_string)
234
232
  break
@@ -302,7 +300,7 @@ module DebugTrace
302
300
  buff.line_feed
303
301
  chars = ''
304
302
  end
305
- if count >= print_options.bytes_limit
303
+ if count >= print_options.output_length_limit
306
304
  buff.no_break_append(@@config.limit_string)
307
305
  break
308
306
  end
@@ -414,11 +412,11 @@ module DebugTrace
414
412
  close_char = ']'
415
413
 
416
414
  if values.is_a?(Hash)
417
- # Array
415
+ # Hash
418
416
  open_char = '{'
419
417
  close_char = '}'
420
418
  elsif values.is_a?(Set)
421
- # Sete
419
+ # Set
422
420
  open_char = 'Set['
423
421
  close_char = ']'
424
422
  end
@@ -461,7 +459,7 @@ module DebugTrace
461
459
  values.each do |element|
462
460
  buff.no_break_append(', ') if index > 0
463
461
 
464
- if index >= print_options.collection_limit
462
+ if index >= print_options.output_size_limit
465
463
  buff.append(@@config.limit_string)
466
464
  break
467
465
  end
@@ -540,15 +538,12 @@ module DebugTrace
540
538
  # @option reflection [TrueClass, FalseClass] use reflection if true
541
539
  # @option minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
542
540
  # @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)
541
+ # @option output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
542
+ # @option output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
546
543
  # @option reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
547
544
  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)
545
+ reflection: false, minimum_output_size: -1, minimum_output_length: -1,
546
+ output_size_limit: -1, output_length_limit: -1, reflection_limit: -1)
552
547
  @@thread_mutex.synchronize do
553
548
  print_start
554
549
  return value unless @@config.enabled?
@@ -565,22 +560,17 @@ module DebugTrace
565
560
  else
566
561
  # with value
567
562
  print_options = PrintOptions.new(
568
- reflection,
569
- minimum_output_size, minimum_output_length,
570
- collection_limit, bytes_limit,
571
- string_limit, reflection_limit
563
+ reflection, minimum_output_size, minimum_output_length,
564
+ output_size_limit, output_length_limit, reflection_limit
572
565
  )
573
566
  @@last_log_buff = to_string(name, value, print_options)
574
567
  end
575
568
 
576
569
  # append print suffix
577
- location = caller_locations(3, 3)[0]
578
- name = !location.nil? ? location.base_label : ''
579
- filename = !location.nil? ? File.basename(location.absolute_path) : ''
580
- lineno = !location.nil? ? location.lineno : 0
570
+ location = Location.new(caller_locations(3, 3)[0])
581
571
 
582
572
  @@last_log_buff.no_break_append(
583
- format(@@config.print_suffix_format, name, filename, lineno)
573
+ format(@@config.print_suffix_format, location.name, location.filename, location.lineno)
584
574
  )
585
575
 
586
576
  @@last_log_buff.line_feed
@@ -604,16 +594,8 @@ module DebugTrace
604
594
  return unless @@config.enabled?
605
595
 
606
596
  state = current_state
607
-
608
- location = caller_locations(3, 3)[0]
609
- name = !location.nil? ? location.base_label : ''
610
- filename = !location.nil? ? File.basename(location.absolute_path) : ''
611
- lineno = !location.nil? ? location.lineno : 0
612
-
613
- parent_location = caller_locations(4, 4)[0]
614
- parent_name = !parent_location.nil? ? parent_location.base_label : ''
615
- parent_filename = !parent_location.nil? ? File.basename(parent_location.absolute_path) : ''
616
- parent_lineno = !parent_location.nil? ? parent_location.lineno : 0
597
+ location = Location.new(caller_locations(3, 3)[0])
598
+ parent_location = Location.new(caller_locations(4, 4)[0])
617
599
 
618
600
  indent_string = get_indent_string(state.nest_level, 0)
619
601
  if state.nest_level < state.previous_nest_level || @@last_log_buff.multi_lines?
@@ -622,7 +604,9 @@ module DebugTrace
622
604
 
623
605
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
624
606
  @@last_log_buff.no_break_append(
625
- format(@@config.enter_format, name, filename, lineno, parent_name, parent_filename, parent_lineno)
607
+ format(@@config.enter_format,
608
+ location.name, location.filename, location.lineno,
609
+ parent_location.name, parent_location.filename, parent_location.lineno)
626
610
  )
627
611
  @@last_log_buff.line_feed
628
612
  @@logger.print(indent_string + @@last_log_buff.lines[0].log)
@@ -641,11 +625,7 @@ module DebugTrace
641
625
  return return_value unless @@config.enabled?
642
626
 
643
627
  state = current_state
644
-
645
- location = caller_locations(3, 3)[0]
646
- name = location.base_label
647
- filename = File.basename(location.absolute_path)
648
- lineno = location.lineno
628
+ location = Location.new(caller_locations(3, 3)[0])
649
629
 
650
630
  if @@last_log_buff.multi_lines?
651
631
  @@logger.print(get_indent_string(state.nest_level, 0)) # Empty Line
@@ -655,7 +635,7 @@ module DebugTrace
655
635
 
656
636
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
657
637
  @@last_log_buff.no_break_append(
658
- format(@@config.leave_format, name, filename, lineno, time)
638
+ format(@@config.leave_format, location.name, location.filename, location.lineno, time)
659
639
  )
660
640
  @@last_log_buff.line_feed
661
641
  @@logger.print(get_indent_string(state.nest_level, 0) + @@last_log_buff.lines[0].log)
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.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masato Kokubo
@@ -20,6 +20,7 @@ extra_rdoc_files: []
20
20
  files:
21
21
  - ".rubocop.yml"
22
22
  - CHANGELOG.md
23
+ - CHANGELOG_ja.md
23
24
  - LICENSE.txt
24
25
  - README.md
25
26
  - README_ja.md
@@ -29,6 +30,7 @@ files:
29
30
  - lib/debugtrace.rb
30
31
  - lib/debugtrace/common.rb
31
32
  - lib/debugtrace/config.rb
33
+ - lib/debugtrace/location.rb
32
34
  - lib/debugtrace/log_buffer.rb
33
35
  - lib/debugtrace/loggers.rb
34
36
  - lib/debugtrace/state.rb