debugtrace 1.2.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 +9 -0
- data/CHANGELOG_ja.md +16 -7
- data/README.md +40 -39
- data/README_ja.md +37 -36
- data/lib/debugtrace/location.rb +35 -35
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +17 -6
- 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: 532ea3832059c93712bc0b142ac493de5ae5ab71c7f312a46be3a6f0a251c8a0
|
4
|
+
data.tar.gz: 970f31cbf67a4f3f4d2f316d4ab3cad0fbe8646d5aa8accd7540d8bce3e0ae2c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a70f4ce98f48793d6a88b8ebe6140ceecf53c70aa66f41c3f850159d69e447d28d328d4bc1a2108ca4a13d64400741948fb3ab152953fcfecd2828440510176
|
7
|
+
data.tar.gz: 94cee6b4120f217fc3be0bfbf0670388da26a5c3e11e709fa5b3215914b48cae0853a6bd421ec692f0fa8db28781a89dd648c22280c793ffc4f920899c1a7a9e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
## 1.3.1 - July 15, 2025
|
2
|
+
* Even if `string_as_bytes: true` is specified in the `print` method, if the string encoding is not `ASCII_8BIT`, it will be output as a normal string.
|
3
|
+
* If an exception is thrown when trying to output as a normal string, it will be output in hexadecimal.
|
4
|
+
|
5
|
+
## 1.3.0 - July 12, 2025
|
6
|
+
|
7
|
+
* Added optional argument `string_as_bytes` (default: `false`) to the `print` method. The string will be output in hexadecimal if it is `true`.
|
8
|
+
* Hexadecimal output of strings with encoding `ASCII_8BIT` has been discontinued.
|
9
|
+
|
1
10
|
## 1.2.0 - July 5, 2025
|
2
11
|
|
3
12
|
* Changed source file name output to a relative path from the current directory.
|
data/CHANGELOG_ja.md
CHANGED
@@ -1,29 +1,38 @@
|
|
1
|
+
## 1.3.1 - 2025/7/15
|
2
|
+
* `print`メソッドで`string_as_bytes: true`が指定されていても文字列のエンコードが`ASCII_8BIT`ではない場合は、通常の文字列として出力するようにしました。
|
3
|
+
* 通常の文字列として出力しようとして例外がスローされた場合は、16進数で出力するようにしました。
|
4
|
+
|
5
|
+
## 1.3.0 - 2025/7/12
|
6
|
+
|
7
|
+
* `print`メソッドにオプション引数`string_as_bytes`(デフォルト: `false`)を追加しました。`true`を指定した場合は、文字列を16進数で出力します。
|
8
|
+
* エンコーディングが`ASCII_8BIT`の文字列の16進数出力を廃止しました。
|
9
|
+
|
1
10
|
## 1.2.0 - 2025/7/5
|
2
11
|
|
3
|
-
*
|
4
|
-
*
|
12
|
+
* ソースファイル名の出力をカレントディレクトリからの相対パスに変更しました。
|
13
|
+
* メソッド名の出力にクラス名を追加しました。
|
5
14
|
|
6
15
|
## 1.1.2 - 2025/7/2
|
7
16
|
|
8
|
-
条件によって`print
|
17
|
+
条件によって`print`メソッドで例外がスローされるバグを修正しました。
|
9
18
|
|
10
19
|
## 1.1.1 - 2025/7/1
|
11
20
|
|
12
|
-
条件によって`enter`, `leave`, `print
|
21
|
+
条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正しました。
|
13
22
|
|
14
23
|
## 1.1.0 - 2025/5/25
|
15
24
|
|
16
|
-
`print`メソッドで`Array`, `Hash`および`Set
|
25
|
+
`print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間で改行が行われないバグの修正しました。
|
17
26
|
|
18
27
|
#### 仕様変更
|
19
28
|
|
20
|
-
* `print
|
29
|
+
* `print`メソッドの以下のキーワード引数名を変更し、`debugtrace.yml`の同名のプロパティ名も変更しました。
|
21
30
|
* `output_size_limit` ← `collection_limit`
|
22
31
|
* `output_length_limit` ← `string_limit` および `bytes_limit` _(統一)_
|
23
32
|
|
24
33
|
## 1.0.1 - 2025/5/19
|
25
34
|
|
26
|
-
環境変数 `DEBUGTRACE_CONFIG`
|
35
|
+
環境変数 `DEBUGTRACE_CONFIG` が設定されていない場合にエラーが発生するバグを修正しました。
|
27
36
|
|
28
37
|
## 1.0.0 - 2025/5/18
|
29
38
|
|
data/README.md
CHANGED
@@ -77,32 +77,32 @@ func1
|
|
77
77
|
```
|
78
78
|
|
79
79
|
```log
|
80
|
-
2025-07-
|
81
|
-
2025-07-
|
82
|
-
2025-07-
|
83
|
-
2025-07-
|
84
|
-
2025-07-
|
85
|
-
2025-07-
|
86
|
-
2025-07-
|
87
|
-
2025-07-
|
88
|
-
2025-07-
|
89
|
-
2025-07-
|
90
|
-
2025-07-
|
91
|
-
2025-07-
|
92
|
-
2025-07-
|
93
|
-
2025-07-
|
94
|
-
2025-07-
|
95
|
-
2025-07-
|
96
|
-
2025-07-
|
97
|
-
2025-07-
|
98
|
-
2025-07-
|
99
|
-
2025-07-
|
100
|
-
2025-07-
|
101
|
-
2025-07-
|
102
|
-
2025-07-
|
103
|
-
2025-07-
|
104
|
-
2025-07-
|
105
|
-
2025-07-
|
80
|
+
2025-07-15 20:45:14.106+09:00 DebugTrace-rb 1.3.1 on Ruby 3.4.4
|
81
|
+
2025-07-15 20:45:14.106+09:00 config file: ./debugtrace.yml
|
82
|
+
2025-07-15 20:45:14.106+09:00 logger: StdErrLogger
|
83
|
+
2025-07-15 20:45:14.106+09:00
|
84
|
+
2025-07-15 20:45:14.106+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-07-15 20:45:14.106+09:00
|
86
|
+
2025-07-15 20:45:14.106+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-07-15 20:45:14.106+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-07-15 20:45:14.106+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-07-15 20:45:14.106+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-07-15 20:45:14.106+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.011 ms
|
91
|
+
2025-07-15 20:45:14.106+09:00 | |
|
92
|
+
2025-07-15 20:45:14.106+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-07-15 20:45:14.106+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.019 ms
|
94
|
+
2025-07-15 20:45:14.106+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.229 ms
|
95
|
+
2025-07-15 20:45:14.106+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.361 ms
|
96
|
+
2025-07-15 20:45:14.107+09:00
|
97
|
+
2025-07-15 20:45:14.107+09:00 contacts = [
|
98
|
+
2025-07-15 20:45:14.107+09:00 Contact{
|
99
|
+
2025-07-15 20:45:14.107+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-07-15 20:45:14.107+09:00 },
|
101
|
+
2025-07-15 20:45:14.107+09:00 Contact{
|
102
|
+
2025-07-15 20:45:14.107+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-07-15 20:45:14.107+09:00 @birthday: 1992-03-04
|
104
|
+
2025-07-15 20:45:14.107+09:00 }
|
105
|
+
2025-07-15 20:45:14.107+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. List of methods
|
@@ -120,28 +120,29 @@ DebugTrace module has the following methods.
|
|
120
120
|
<tr>
|
121
121
|
<td><code>enter</code></td>
|
122
122
|
<td><i>None</i></td>
|
123
|
-
<td><
|
123
|
+
<td><code>nil</code></td>
|
124
124
|
<td>Outputs the start of the method to the log.</td>
|
125
125
|
</tr>
|
126
126
|
<tr>
|
127
127
|
<td><code>leave</code></td>
|
128
|
-
<td><code>return_value</code>: return value of this method<small>(Optional)</small></td>
|
129
|
-
<td><code>return_value</code>
|
128
|
+
<td><code>return_value</code>: return value of this method <small>(Optional)</small></td>
|
129
|
+
<td><code>return_value</code> (<code>nil</code> if <code>return_value</code> is omitted)</td>
|
130
130
|
<td>Output the end of the method to the log.</td>
|
131
131
|
</tr>
|
132
132
|
<tr>
|
133
133
|
<td><code>print</code></td>
|
134
134
|
<td>
|
135
|
-
<code>name</code>: the value name
|
136
|
-
<code>value</code>: the value <small>(Optional)</small
|
137
|
-
<small><i>The following arguments are keyword arguments and optional</i></small
|
138
|
-
<code>reflection</code>: reflection is used aggressively if <code>true</code>, used passively if <code>false</code
|
139
|
-
<
|
140
|
-
<
|
141
|
-
<code>
|
142
|
-
<code>
|
143
|
-
<code>
|
144
|
-
<code>
|
135
|
+
<p><code>name</code>: the value name</p>
|
136
|
+
<p><code>value</code>: the value <small>(Optional)</small></p>
|
137
|
+
<small><i>The following arguments are keyword arguments and optional</i></small></p>
|
138
|
+
<p><code>reflection</code>: reflection is used aggressively if <code>true</code>, used passively if <code>false</code> (Default: <code>false</code>)</p>
|
139
|
+
<p><code>string_as_bytes</code>: Output strings which encoding is <code>ASCII_8BIT</code> in hexadecimal if <code>true</code> <small>(Default: <code>false</code>)</small></p>
|
140
|
+
<small><i>The following arguments can be specified in debugtrace.yml (argument specification takes precedence)</i></small></p>
|
141
|
+
<p><code>minimum_output_size</code>: The minimum number of elements to print for <code>Array</code>, <code>Hash</code> and <code>Set</code></p>
|
142
|
+
<p><code>minimum_output_length</code>: The minimum length to print the length of the string<br>
|
143
|
+
<p><code>output_size_limit</code>: The limit on the number of elements output for <code>Map</code>, <code>Hash</code> and <code>Set</code></p>
|
144
|
+
<p><code>output_length_limit</code>: The limit on the number of characters that can be output from a string<br>
|
145
|
+
<p><code>reflection_limit</code>: The limit of reflection nesting</p>
|
145
146
|
</td>
|
146
147
|
<td>the argument value if it is specified, otherwise <code>nil</code></td>
|
147
148
|
<td>
|
data/README_ja.md
CHANGED
@@ -77,32 +77,32 @@ DebugTrace.print('contacts', contacts)
|
|
77
77
|
```
|
78
78
|
|
79
79
|
```log
|
80
|
-
2025-07-
|
81
|
-
2025-07-
|
82
|
-
2025-07-
|
83
|
-
2025-07-
|
84
|
-
2025-07-
|
85
|
-
2025-07-
|
86
|
-
2025-07-
|
87
|
-
2025-07-
|
88
|
-
2025-07-
|
89
|
-
2025-07-
|
90
|
-
2025-07-
|
91
|
-
2025-07-
|
92
|
-
2025-07-
|
93
|
-
2025-07-
|
94
|
-
2025-07-
|
95
|
-
2025-07-
|
96
|
-
2025-07-
|
97
|
-
2025-07-
|
98
|
-
2025-07-
|
99
|
-
2025-07-
|
100
|
-
2025-07-
|
101
|
-
2025-07-
|
102
|
-
2025-07-
|
103
|
-
2025-07-
|
104
|
-
2025-07-
|
105
|
-
2025-07-
|
80
|
+
2025-07-15 20:45:14.106+09:00 DebugTrace-rb 1.3.1 on Ruby 3.4.4
|
81
|
+
2025-07-15 20:45:14.106+09:00 config file: ./debugtrace.yml
|
82
|
+
2025-07-15 20:45:14.106+09:00 logger: StdErrLogger
|
83
|
+
2025-07-15 20:45:14.106+09:00
|
84
|
+
2025-07-15 20:45:14.106+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-07-15 20:45:14.106+09:00
|
86
|
+
2025-07-15 20:45:14.106+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-07-15 20:45:14.106+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-07-15 20:45:14.106+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-07-15 20:45:14.106+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-07-15 20:45:14.106+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.011 ms
|
91
|
+
2025-07-15 20:45:14.106+09:00 | |
|
92
|
+
2025-07-15 20:45:14.106+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-07-15 20:45:14.106+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.019 ms
|
94
|
+
2025-07-15 20:45:14.106+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.229 ms
|
95
|
+
2025-07-15 20:45:14.106+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.361 ms
|
96
|
+
2025-07-15 20:45:14.107+09:00
|
97
|
+
2025-07-15 20:45:14.107+09:00 contacts = [
|
98
|
+
2025-07-15 20:45:14.107+09:00 Contact{
|
99
|
+
2025-07-15 20:45:14.107+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-07-15 20:45:14.107+09:00 },
|
101
|
+
2025-07-15 20:45:14.107+09:00 Contact{
|
102
|
+
2025-07-15 20:45:14.107+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-07-15 20:45:14.107+09:00 @birthday: 1992-03-04
|
104
|
+
2025-07-15 20:45:14.107+09:00 }
|
105
|
+
2025-07-15 20:45:14.107+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. メソッド一覧
|
@@ -120,7 +120,7 @@ DebugTraceモジュールには以下のメソッドがあります。
|
|
120
120
|
<tr>
|
121
121
|
<td><code>enter</code></td>
|
122
122
|
<td>なし</td>
|
123
|
-
<td
|
123
|
+
<td><code>nil</code></td>
|
124
124
|
<td>メソッドの開始のログを出力する</td>
|
125
125
|
</tr>
|
126
126
|
<tr>
|
@@ -132,16 +132,17 @@ DebugTraceモジュールには以下のメソッドがあります。
|
|
132
132
|
<tr>
|
133
133
|
<td><code>print</code></td>
|
134
134
|
<td>
|
135
|
-
<code>name</code>:
|
136
|
-
<code>value</code>: 値 <small>(省略可)</small
|
137
|
-
<small><i>以降の引数は、キーワード引数で省略可</i></small
|
138
|
-
<code>reflection</code>: <code>true</code>ならリフレクションを積極的に使用、<code>false</code>なら消極的に使用 <small>(デフォルト: <code>false</code>)</small
|
135
|
+
<p><code>name</code>: 値の名前</p>
|
136
|
+
<p><code>value</code>: 値 <small>(省略可)</small></p>
|
137
|
+
<small><i>以降の引数は、キーワード引数で省略可</i></small>
|
138
|
+
<code>reflection</code>: <code>true</code>ならリフレクションを積極的に使用、<code>false</code>なら消極的に使用 <small>(デフォルト: <code>false</code>)</small></p>
|
139
|
+
<p><code>string_as_bytes</code>: <code>true</code>ならエンコードが<code>ASCII_8BIT</code>の文字列を16進数で出力する<small>(デフォルト: <code>false</code>)</small></p>
|
139
140
|
<small><i>以降の引数は、debugtrace.ymlで指定可能 (引数指定が優先)</i></small><br>
|
140
|
-
<code>minimum_output_size</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code
|
141
|
-
<code>minimum_output_length</code>: 文字列の長さを出力する最小の長さ<br>
|
142
|
-
<code>output_size_limit</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code
|
143
|
-
<code>output_length_limit</code>:
|
144
|
-
<code>reflection_limit</code>:
|
141
|
+
<p><code>minimum_output_size</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素数を出力する最小要素数</p>
|
142
|
+
<p><code>minimum_output_length</code>: 文字列の長さを出力する最小の長さ<br>
|
143
|
+
<p><code>output_size_limit</code>: <code>Array</code>, <code>Hash</code>および<code>Set</code>の要素の出力数の制限値</p>
|
144
|
+
<p><code>output_length_limit</code>: 文字列の出力文字数の制限値</p>
|
145
|
+
<p><code>reflection_limit</code>: リフレクションのネスト数の制限値</p>
|
145
146
|
</td>
|
146
147
|
<td>値の指定があれば引数値、なければ<code>nil</code></td>
|
147
148
|
<td>
|
data/lib/debugtrace/location.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
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 :path
|
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
|
-
@path = 'unknown'
|
18
|
-
@lineno = 0
|
19
|
-
else
|
20
|
-
@name = caller_location.label
|
21
|
-
if @name.start_with?('Object#')
|
22
|
-
@name = caller_location.base_label
|
23
|
-
end
|
24
|
-
@path = caller_location.path || 'unknown'
|
25
|
-
@lineno = caller_location.lineno
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Returns a string representation of this object.
|
30
|
-
#
|
31
|
-
# @return [String] A string representation of this object
|
32
|
-
def to_s()
|
33
|
-
return "(Location){name: #{@name}, path: #{@path}, lineno: #{@lineno}"
|
34
|
-
end
|
35
|
-
end
|
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 :path
|
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
|
+
@path = 'unknown'
|
18
|
+
@lineno = 0
|
19
|
+
else
|
20
|
+
@name = caller_location.label
|
21
|
+
if @name.start_with?('Object#')
|
22
|
+
@name = caller_location.base_label
|
23
|
+
end
|
24
|
+
@path = caller_location.path || 'unknown'
|
25
|
+
@lineno = caller_location.lineno
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns a string representation of this object.
|
30
|
+
#
|
31
|
+
# @return [String] A string representation of this object
|
32
|
+
def to_s()
|
33
|
+
return "(Location){name: #{@name}, path: #{@path}, lineno: #{@lineno}"
|
34
|
+
end
|
35
|
+
end
|
data/lib/debugtrace/version.rb
CHANGED
data/lib/debugtrace.rb
CHANGED
@@ -78,7 +78,6 @@ module DebugTrace
|
|
78
78
|
|
79
79
|
return unless @@config.enabled?
|
80
80
|
|
81
|
-
config_path = @@config.config == nil ? @@config.config_path : File.expand_path(@@config.config_path)
|
82
81
|
@@logger.print("DebugTrace-rb #{DebugTrace::VERSION} on Ruby #{RUBY_VERSION}")
|
83
82
|
@@logger.print(" config file: #{config_path}")
|
84
83
|
@@logger.print(" logger: #{@@logger}")
|
@@ -86,12 +85,13 @@ module DebugTrace
|
|
86
85
|
|
87
86
|
# Contains options to pass to the print method.
|
88
87
|
class PrintOptions
|
89
|
-
attr_reader :reflection, :minimum_output_size, :minimum_output_length,
|
88
|
+
attr_reader :reflection, :string_as_bytes, :minimum_output_size, :minimum_output_length,
|
90
89
|
:output_size_limit, :output_length_limit, :reflection_limit
|
91
90
|
|
92
91
|
# Initializes this object.
|
93
92
|
#
|
94
93
|
# @param reflection [TrueClass, FalseClass] use reflection if true
|
94
|
+
# @param string_as_bytes [TrueClass, FalseClass] print string as byte array if true
|
95
95
|
# @param minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
|
96
96
|
# @param minimum_output_length [Integer] the minimum value to output the length of String and byte array (overrides debugtarace.yml value)
|
97
97
|
# @param output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
|
@@ -99,6 +99,7 @@ module DebugTrace
|
|
99
99
|
# @param reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
|
100
100
|
def initialize(
|
101
101
|
reflection,
|
102
|
+
string_as_bytes,
|
102
103
|
minimum_output_size,
|
103
104
|
minimum_output_length,
|
104
105
|
output_size_limit,
|
@@ -106,6 +107,7 @@ module DebugTrace
|
|
106
107
|
reflection_limit
|
107
108
|
)
|
108
109
|
@reflection = reflection
|
110
|
+
@string_as_bytes = string_as_bytes
|
109
111
|
@minimum_output_size = minimum_output_size == -1 ? DebugTrace.config.minimum_output_size : minimum_output_size
|
110
112
|
@minimum_output_length = minimum_output_length == -1 ? DebugTrace.config.minimum_output_length : minimum_output_length
|
111
113
|
@output_size_limit = output_size_limit == -1 ? DebugTrace.config.output_size_limit : output_size_limit
|
@@ -166,8 +168,16 @@ module DebugTrace
|
|
166
168
|
when Module
|
167
169
|
buff.append(value.name).no_break_append(' module')
|
168
170
|
when String
|
169
|
-
value_buff =
|
170
|
-
|
171
|
+
value_buff = nil
|
172
|
+
if print_options.string_as_bytes && value.encoding == Encoding::ASCII_8BIT
|
173
|
+
value_buff = to_string_bytes(value, print_options)
|
174
|
+
else
|
175
|
+
begin
|
176
|
+
value_buff = to_string_str(value, print_options)
|
177
|
+
rescue
|
178
|
+
value_buff = to_string_bytes(value, print_options)
|
179
|
+
end
|
180
|
+
end
|
171
181
|
buff.append_buffer(value_buff)
|
172
182
|
when DateTime, Time
|
173
183
|
buff.append(value.strftime('%Y-%m-%d %H:%M:%S.%L%:z'))
|
@@ -540,13 +550,14 @@ module DebugTrace
|
|
540
550
|
# @param name [String] a message if the value is not specified, otherwise the value name
|
541
551
|
# @option value [Object] the value
|
542
552
|
# @option reflection [TrueClass, FalseClass] use reflection if true
|
553
|
+
# @param string_as_bytes [TrueClass, FalseClass] print string as byte array if true
|
543
554
|
# @option minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
|
544
555
|
# @option minimum_output_length [Integer] the minimum value to output the length of String and byte array (overrides debugtarace.yml value)
|
545
556
|
# @option output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
|
546
557
|
# @option output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
|
547
558
|
# @option reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
|
548
559
|
def self.print(name, value = @@DO_NOT_OUTPUT,
|
549
|
-
reflection: false, minimum_output_size: -1, minimum_output_length: -1,
|
560
|
+
reflection: false, string_as_bytes: false, minimum_output_size: -1, minimum_output_length: -1,
|
550
561
|
output_size_limit: -1, output_length_limit: -1, reflection_limit: -1)
|
551
562
|
@@thread_mutex.synchronize do
|
552
563
|
print_start
|
@@ -564,7 +575,7 @@ module DebugTrace
|
|
564
575
|
else
|
565
576
|
# with value
|
566
577
|
print_options = PrintOptions.new(
|
567
|
-
reflection, minimum_output_size, minimum_output_length,
|
578
|
+
reflection, string_as_bytes, minimum_output_size, minimum_output_length,
|
568
579
|
output_size_limit, output_length_limit, reflection_limit
|
569
580
|
)
|
570
581
|
@@last_log_buff = to_string(name, value, print_options)
|