debugtrace 1.2.0 → 1.3.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/CHANGELOG_ja.md +12 -7
- data/README.md +14 -13
- data/README_ja.md +11 -10
- data/lib/debugtrace/location.rb +35 -35
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +8 -5
- 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: afb02cff204f024316f82e26158c1bae6d0875426a121527e46dd47fc8a7c2a8
|
4
|
+
data.tar.gz: 52f5a47c52c4c2d33009f2f29391215d58ab61dc9726bf6cb2d9b8ebf49b0579
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4c61532b60b0d9055cfb1e28fea67a4967baef7ee2956898f29d050ff75501d65453a7ce833c5af0fe10915593dfe6188cdd99884557aa43f21e1488f117f4a
|
7
|
+
data.tar.gz: 7b3eed480352befe9fd66d96268106e0ec5ddb2e6008df42341529b04bf235765e8d0cf363da5dc781496e32a57214ba193345a0bb01dcd9fdf4bf44e802c33e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## 1.3.0 - July 12, 2025
|
2
|
+
|
3
|
+
* Added optional argument `string_as_bytes` (default: `false`) to the `print` method. The string will be output in hexadecimal if it is `true`.
|
4
|
+
* Hexadecimal output of strings with encoding `ASCII_8BIT` has been discontinued.
|
5
|
+
|
1
6
|
## 1.2.0 - July 5, 2025
|
2
7
|
|
3
8
|
* Changed source file name output to a relative path from the current directory.
|
data/CHANGELOG_ja.md
CHANGED
@@ -1,29 +1,34 @@
|
|
1
|
+
## 1.3.0 - 2025/7/12
|
2
|
+
|
3
|
+
* `print`メソッドにオプション引数`string_as_bytes`(デフォルト: `false`)を追加しました。`true`を指定した場合は、文字列を16進数で出力します。
|
4
|
+
* エンコーディングが`ASCII_8BIT`の文字列の16進数出力を廃止しました。
|
5
|
+
|
1
6
|
## 1.2.0 - 2025/7/5
|
2
7
|
|
3
|
-
*
|
4
|
-
*
|
8
|
+
* ソースファイル名の出力をカレントディレクトリからの相対パスに変更しました。
|
9
|
+
* メソッド名の出力にクラス名を追加しました。
|
5
10
|
|
6
11
|
## 1.1.2 - 2025/7/2
|
7
12
|
|
8
|
-
条件によって`print
|
13
|
+
条件によって`print`メソッドで例外がスローされるバグを修正しました。
|
9
14
|
|
10
15
|
## 1.1.1 - 2025/7/1
|
11
16
|
|
12
|
-
条件によって`enter`, `leave`, `print
|
17
|
+
条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正しました。
|
13
18
|
|
14
19
|
## 1.1.0 - 2025/5/25
|
15
20
|
|
16
|
-
`print`メソッドで`Array`, `Hash`および`Set
|
21
|
+
`print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間で改行が行われないバグの修正しました。
|
17
22
|
|
18
23
|
#### 仕様変更
|
19
24
|
|
20
|
-
* `print
|
25
|
+
* `print`メソッドの以下のキーワード引数名を変更し、`debugtrace.yml`の同名のプロパティ名も変更しました。
|
21
26
|
* `output_size_limit` ← `collection_limit`
|
22
27
|
* `output_length_limit` ← `string_limit` および `bytes_limit` _(統一)_
|
23
28
|
|
24
29
|
## 1.0.1 - 2025/5/19
|
25
30
|
|
26
|
-
環境変数 `DEBUGTRACE_CONFIG`
|
31
|
+
環境変数 `DEBUGTRACE_CONFIG` が設定されていない場合にエラーが発生するバグを修正しました。
|
27
32
|
|
28
33
|
## 1.0.0 - 2025/5/18
|
29
34
|
|
data/README.md
CHANGED
@@ -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 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
@@ -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>なら文字列を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,7 +168,7 @@ module DebugTrace
|
|
166
168
|
when Module
|
167
169
|
buff.append(value.name).no_break_append(' module')
|
168
170
|
when String
|
169
|
-
value_buff =
|
171
|
+
value_buff = print_options.string_as_bytes ?
|
170
172
|
to_string_bytes(value, print_options) : to_string_str(value, print_options)
|
171
173
|
buff.append_buffer(value_buff)
|
172
174
|
when DateTime, Time
|
@@ -540,13 +542,14 @@ module DebugTrace
|
|
540
542
|
# @param name [String] a message if the value is not specified, otherwise the value name
|
541
543
|
# @option value [Object] the value
|
542
544
|
# @option reflection [TrueClass, FalseClass] use reflection if true
|
545
|
+
# @param string_as_bytes [TrueClass, FalseClass] print string as byte array if true
|
543
546
|
# @option minimum_output_size [Integer] the minimum value to output the number of elements for Array and Hash (overrides debugtarace.yml value)
|
544
547
|
# @option minimum_output_length [Integer] the minimum value to output the length of String and byte array (overrides debugtarace.yml value)
|
545
548
|
# @option output_size_limit [Integer] Output limit of collection elements (overrides debugtarace.yml value)
|
546
549
|
# @option output_length_limit [Integer] the limit value of characters for string to output (overrides debugtarace.yml value)
|
547
550
|
# @option reflection_limit [Integer] reflection limits when using reflection (overrides debugtarace.yml value)
|
548
551
|
def self.print(name, value = @@DO_NOT_OUTPUT,
|
549
|
-
reflection: false, minimum_output_size: -1, minimum_output_length: -1,
|
552
|
+
reflection: false, string_as_bytes: false, minimum_output_size: -1, minimum_output_length: -1,
|
550
553
|
output_size_limit: -1, output_length_limit: -1, reflection_limit: -1)
|
551
554
|
@@thread_mutex.synchronize do
|
552
555
|
print_start
|
@@ -564,7 +567,7 @@ module DebugTrace
|
|
564
567
|
else
|
565
568
|
# with value
|
566
569
|
print_options = PrintOptions.new(
|
567
|
-
reflection, minimum_output_size, minimum_output_length,
|
570
|
+
reflection, string_as_bytes, minimum_output_size, minimum_output_length,
|
568
571
|
output_size_limit, output_length_limit, reflection_limit
|
569
572
|
)
|
570
573
|
@@last_log_buff = to_string(name, value, print_options)
|