debugtrace 1.1.1 → 1.2.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 +11 -3
- data/CHANGELOG_ja.md +12 -6
- data/README.md +26 -26
- data/README_ja.md +26 -26
- data/lib/debugtrace/location.rb +8 -6
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +27 -22
- 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: 04bce05e2d9f97e7a4c0e1aa1e4b097a49cd4669615ca56e69ab197d2f2a494b
|
4
|
+
data.tar.gz: 4a6ab354ae3515f2167dd6779027f89fc49e49710a17b9d842570d8ec92a13f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46e1e92e14d5f42f22b208b39911ff6c4f651fa15f4f5be89ace408f6e0448e2a931f1e0983d82d1a831b03f5167cbe2ccd369bf8eed6014cecbb202acdf8c8
|
7
|
+
data.tar.gz: 930dd3f482134f6e39dfc96e64f73c23f8630ac32241aa725e0ebc772c02ccae29f3911f850da5c31e02dac2a87a61af2591a4f8f414d94e09eaf3f3e138f33d
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
+
## 1.2.0 - July 5, 2025
|
2
|
+
|
3
|
+
* Changed source file name output to a relative path from the current directory.
|
4
|
+
* Added class name to method name output.
|
5
|
+
|
6
|
+
## 1.1.2 - July 2, 2025
|
7
|
+
|
8
|
+
Fixed a bug that caused exceptions to be thrown by the `print` methods depending on the conditions.
|
9
|
+
|
1
10
|
## 1.1.1 - July 1, 2025
|
2
11
|
|
3
|
-
|
4
|
-
* Fixed a bug that caused exceptions to be thrown by the `enter`, `leave` and `print` methods depending on the conditions.
|
12
|
+
Fixed a bug that caused exceptions to be thrown by the `enter`, `leave` and `print` methods depending on the conditions.
|
5
13
|
|
6
14
|
## 1.1.0 - May 25, 2025
|
7
15
|
|
8
|
-
### Bug
|
16
|
+
### Bug fix
|
9
17
|
|
10
18
|
* Fixed a bug where line breaks were not inserted between elements when outputting `Array`, `Hash`, and `Set` using the print method.
|
11
19
|
|
data/CHANGELOG_ja.md
CHANGED
@@ -1,13 +1,19 @@
|
|
1
|
+
## 1.2.0 - 2025/7/5
|
2
|
+
|
3
|
+
* ソースファイル名の出力をカレントディレクトリからの相対パスに変更。
|
4
|
+
* メソッド名の出力にクラス名を追加。
|
5
|
+
|
6
|
+
## 1.1.2 - 2025/7/2
|
7
|
+
|
8
|
+
条件によって`print`メソッドで例外がスローされるバグを修正。
|
9
|
+
|
1
10
|
## 1.1.1 - 2025/7/1
|
2
11
|
|
3
|
-
|
4
|
-
* 条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正。
|
12
|
+
条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正。
|
5
13
|
|
6
14
|
## 1.1.0 - 2025/5/25
|
7
15
|
|
8
|
-
|
9
|
-
|
10
|
-
* `print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間での改行が行われないバグの修正。
|
16
|
+
`print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間での改行が行われないバグの修正。
|
11
17
|
|
12
18
|
#### 仕様変更
|
13
19
|
|
@@ -17,7 +23,7 @@
|
|
17
23
|
|
18
24
|
## 1.0.1 - 2025/5/19
|
19
25
|
|
20
|
-
環境変数 `DEBUGTRACE_CONFIG`
|
26
|
+
環境変数 `DEBUGTRACE_CONFIG` が設定されていない場合にエラーが発生するバグを修正。
|
21
27
|
|
22
28
|
## 1.0.0 - 2025/5/18
|
23
29
|
|
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-05 14:38:35.412+09:00 DebugTrace-rb 1.2.0 on Ruby 3.4.4
|
81
|
+
2025-07-05 14:38:35.412+09:00 config file: <No config file>
|
82
|
+
2025-07-05 14:38:35.412+09:00 logger: StdErrLogger
|
83
|
+
2025-07-05 14:38:35.412+09:00
|
84
|
+
2025-07-05 14:38:35.412+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-07-05 14:38:35.412+09:00
|
86
|
+
2025-07-05 14:38:35.412+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-07-05 14:38:35.412+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-07-05 14:38:35.412+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-07-05 14:38:35.412+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-07-05 14:38:35.412+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.012 ms
|
91
|
+
2025-07-05 14:38:35.412+09:00 | |
|
92
|
+
2025-07-05 14:38:35.412+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-07-05 14:38:35.412+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.007 ms
|
94
|
+
2025-07-05 14:38:35.413+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.234 ms
|
95
|
+
2025-07-05 14:38:35.413+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.379 ms
|
96
|
+
2025-07-05 14:38:35.413+09:00
|
97
|
+
2025-07-05 14:38:35.413+09:00 contacts = [
|
98
|
+
2025-07-05 14:38:35.413+09:00 Contact{
|
99
|
+
2025-07-05 14:38:35.413+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-07-05 14:38:35.413+09:00 },
|
101
|
+
2025-07-05 14:38:35.413+09:00 Contact{
|
102
|
+
2025-07-05 14:38:35.413+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-07-05 14:38:35.413+09:00 @birthday: 1992-03-04
|
104
|
+
2025-07-05 14:38:35.413+09:00 }
|
105
|
+
2025-07-05 14:38:35.413+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. List of methods
|
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-05 14:38:35.412+09:00 DebugTrace-rb 1.2.0 on Ruby 3.4.4
|
81
|
+
2025-07-05 14:38:35.412+09:00 config file: <No config file>
|
82
|
+
2025-07-05 14:38:35.412+09:00 logger: StdErrLogger
|
83
|
+
2025-07-05 14:38:35.412+09:00
|
84
|
+
2025-07-05 14:38:35.412+09:00 ______________________________ #72 ______________________________
|
85
|
+
2025-07-05 14:38:35.412+09:00
|
86
|
+
2025-07-05 14:38:35.412+09:00 Enter func1 (examples/readme-example.rb:29) <- <main> (examples/readme-example.rb:35)
|
87
|
+
2025-07-05 14:38:35.412+09:00 | Hello, World! (examples/readme-example.rb:30)
|
88
|
+
2025-07-05 14:38:35.412+09:00 | Enter func2 (examples/readme-example.rb:20) <- func1 (examples/readme-example.rb:31)
|
89
|
+
2025-07-05 14:38:35.412+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:22)
|
90
|
+
2025-07-05 14:38:35.412+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.012 ms
|
91
|
+
2025-07-05 14:38:35.412+09:00 | |
|
92
|
+
2025-07-05 14:38:35.412+09:00 | | Enter Contact#initialize (examples/readme-example.rb:10) <- Class#new (examples/readme-example.rb:23)
|
93
|
+
2025-07-05 14:38:35.412+09:00 | | Leave Contact#initialize (examples/readme-example.rb:15) duration: 0.007 ms
|
94
|
+
2025-07-05 14:38:35.413+09:00 | Leave func2 (examples/readme-example.rb:25) duration: 0.234 ms
|
95
|
+
2025-07-05 14:38:35.413+09:00 Leave func1 (examples/readme-example.rb:32) duration: 0.379 ms
|
96
|
+
2025-07-05 14:38:35.413+09:00
|
97
|
+
2025-07-05 14:38:35.413+09:00 contacts = [
|
98
|
+
2025-07-05 14:38:35.413+09:00 Contact{
|
99
|
+
2025-07-05 14:38:35.413+09:00 @id: 1, @firstName: 'Akane', @lastName: 'Apple', @birthday: 1991-02-03
|
100
|
+
2025-07-05 14:38:35.413+09:00 },
|
101
|
+
2025-07-05 14:38:35.413+09:00 Contact{
|
102
|
+
2025-07-05 14:38:35.413+09:00 @id: 2, @firstName: 'Yukari', @lastName: 'Apple',
|
103
|
+
2025-07-05 14:38:35.413+09:00 @birthday: 1992-03-04
|
104
|
+
2025-07-05 14:38:35.413+09:00 }
|
105
|
+
2025-07-05 14:38:35.413+09:00 ] (examples/readme-example.rb:36)
|
106
106
|
```
|
107
107
|
|
108
108
|
### 4. メソッド一覧
|
data/lib/debugtrace/location.rb
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
# Contains source location information.
|
6
6
|
class Location
|
7
7
|
attr_reader :name
|
8
|
-
attr_reader :
|
8
|
+
attr_reader :path
|
9
9
|
attr_reader :lineno
|
10
10
|
|
11
11
|
# Initializes this object.
|
@@ -14,12 +14,14 @@ class Location
|
|
14
14
|
def initialize(caller_location)
|
15
15
|
if caller_location == nil
|
16
16
|
@name = 'unknown'
|
17
|
-
@
|
17
|
+
@path = 'unknown'
|
18
18
|
@lineno = 0
|
19
19
|
else
|
20
|
-
@name = caller_location.
|
21
|
-
|
22
|
-
|
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'
|
23
25
|
@lineno = caller_location.lineno
|
24
26
|
end
|
25
27
|
end
|
@@ -28,6 +30,6 @@ class Location
|
|
28
30
|
#
|
29
31
|
# @return [String] A string representation of this object
|
30
32
|
def to_s()
|
31
|
-
return "(Location){name: #{@name},
|
33
|
+
return "(Location){name: #{@name}, path: #{@path}, lineno: #{@lineno}"
|
32
34
|
end
|
33
35
|
end
|
data/lib/debugtrace/version.rb
CHANGED
data/lib/debugtrace.rb
CHANGED
@@ -181,25 +181,29 @@ module DebugTrace
|
|
181
181
|
buff.append_buffer(value_buff)
|
182
182
|
else
|
183
183
|
reflection = print_options.reflection || value.class.superclass == Struct
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
184
|
+
|
185
|
+
begin
|
186
|
+
to_s_string = reflection ? '' : value.to_s
|
187
|
+
if reflection || to_s_string.start_with?('#<')
|
188
|
+
# use reflection
|
189
|
+
value_buff = LogBuffer.new(@@config.data_output_width)
|
190
|
+
if @@reflected_objects.any? { |obj| value.equal?(obj) }
|
191
|
+
# cyclic reference
|
192
|
+
value_buff.no_break_append(@@config.circular_reference_string)
|
193
|
+
elsif @@reflected_objects.length > print_options.reflection_limit
|
194
|
+
# over reflection level limitation
|
195
|
+
value_buff.no_break_append(@@config.limit_string)
|
196
|
+
else
|
197
|
+
@@reflected_objects.push(value)
|
198
|
+
value_buff = to_string_reflection(value, print_options)
|
199
|
+
@@reflected_objects.pop
|
200
|
+
end
|
201
|
+
buff.append_buffer(value_buff)
|
195
202
|
else
|
196
|
-
|
197
|
-
value_buff = to_string_reflection(value, print_options)
|
198
|
-
@@reflected_objects.pop
|
203
|
+
buff.append(to_s_string)
|
199
204
|
end
|
200
|
-
|
201
|
-
|
202
|
-
buff.append(to_s_string)
|
205
|
+
rescue => e
|
206
|
+
buff.append("Raised #{e.class.to_s}: '#{e.message}'")
|
203
207
|
end
|
204
208
|
end
|
205
209
|
end
|
@@ -570,7 +574,7 @@ module DebugTrace
|
|
570
574
|
location = Location.new(caller_locations(3, 3)[0])
|
571
575
|
|
572
576
|
@@last_log_buff.no_break_append(
|
573
|
-
format(@@config.print_suffix_format, location.name, location.
|
577
|
+
format(@@config.print_suffix_format, location.name, location.path, location.lineno)
|
574
578
|
)
|
575
579
|
|
576
580
|
@@last_log_buff.line_feed
|
@@ -605,14 +609,15 @@ module DebugTrace
|
|
605
609
|
@@last_log_buff = LogBuffer.new(@@config.data_output_width)
|
606
610
|
@@last_log_buff.no_break_append(
|
607
611
|
format(@@config.enter_format,
|
608
|
-
location.name, location.
|
609
|
-
parent_location.name, parent_location.
|
612
|
+
location.name, location.path, location.lineno,
|
613
|
+
parent_location.name, parent_location.path, parent_location.lineno)
|
610
614
|
)
|
611
615
|
@@last_log_buff.line_feed
|
612
616
|
@@logger.print(indent_string + @@last_log_buff.lines[0].log)
|
613
617
|
|
614
618
|
state.up_nest
|
615
619
|
end
|
620
|
+
return nil
|
616
621
|
end
|
617
622
|
|
618
623
|
# Prints the end of the method.
|
@@ -635,12 +640,12 @@ module DebugTrace
|
|
635
640
|
|
636
641
|
@@last_log_buff = LogBuffer.new(@@config.data_output_width)
|
637
642
|
@@last_log_buff.no_break_append(
|
638
|
-
format(@@config.leave_format, location.name, location.
|
643
|
+
format(@@config.leave_format, location.name, location.path, location.lineno, time)
|
639
644
|
)
|
640
645
|
@@last_log_buff.line_feed
|
641
646
|
@@logger.print(get_indent_string(state.nest_level, 0) + @@last_log_buff.lines[0].log)
|
642
|
-
return return_value
|
643
647
|
end
|
648
|
+
return return_value
|
644
649
|
end
|
645
650
|
|
646
651
|
# Returns the last print string.
|