debugtrace 1.1.0 → 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 +4 -4
- data/CHANGELOG.md +5 -0
- data/CHANGELOG_ja.md +24 -0
- data/README.md +30 -31
- data/README_ja.md +37 -36
- data/examples/readme-example.rb +5 -5
- data/lib/debugtrace/location.rb +33 -0
- data/lib/debugtrace/version.rb +1 -1
- data/lib/debugtrace.rb +10 -22
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 329e4c78cb0dd2a7778ec83d17c6b8b6a98bddcb27360322fa757d9c0779fd04
|
4
|
+
data.tar.gz: f1b7c56f4c029320a869c71e84babbf521f1b43dae89be907bca1a8e00f0dda5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72de200654893939ec841d1c70ba56be2f028b2afed076fbc649ccdc07b67a8a71705719e97e7bd5d3379143c43be6f4ec00c6c3f9e5308dec6132ff5a963957
|
7
|
+
data.tar.gz: 1159e8da5fc15885699615004d0ef361317f748281c7e90b284119adf64dcc6835578959cae095aed2640997ddb4be226437ca2049e5041c0911e2096dc5e970
|
data/CHANGELOG.md
CHANGED
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.
|
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-
|
82
|
-
2025-
|
83
|
-
2025-
|
84
|
-
2025-
|
85
|
-
2025-
|
86
|
-
2025-
|
87
|
-
2025-
|
88
|
-
2025-
|
89
|
-
2025-
|
90
|
-
2025-
|
91
|
-
2025-
|
92
|
-
2025-
|
93
|
-
2025-
|
94
|
-
2025-
|
95
|
-
2025-
|
96
|
-
2025-
|
97
|
-
2025-
|
98
|
-
2025-
|
99
|
-
2025-
|
100
|
-
2025-
|
101
|
-
2025-
|
102
|
-
2025-
|
103
|
-
2025-
|
104
|
-
2025-
|
105
|
-
2025-
|
106
|
-
2025-
|
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
|
@@ -578,5 +577,5 @@ You can specify the following properties in debugtrace.yml.
|
|
578
577
|
|
579
578
|
[MIT License(MIT)](LICENSE.txt)
|
580
579
|
|
581
|
-
_
|
580
|
+
_© 2025 Masato Kokubo_
|
582
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
|
-
|
8
|
+
### 1. 特徴
|
9
9
|
|
10
10
|
* 呼び出し元のメソッド名、ソースファイル名および行番号を自動的に出力。
|
11
11
|
* メソッドやオブジェクトのネストで、ログを自動的にインデント 。
|
@@ -13,7 +13,7 @@
|
|
13
13
|
* リフレクションを使用してオブジェクト内容の出力が可能。
|
14
14
|
* `debugtrace.yml`ファイルの設定で、出力内容のカスタマイズが可能。
|
15
15
|
|
16
|
-
|
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
|
-
|
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.
|
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-
|
80
|
-
2025-
|
81
|
-
2025-
|
82
|
-
2025-
|
83
|
-
2025-
|
84
|
-
2025-
|
85
|
-
2025-
|
86
|
-
2025-
|
87
|
-
2025-
|
88
|
-
2025-
|
89
|
-
2025-
|
90
|
-
2025-
|
91
|
-
2025-
|
92
|
-
2025-
|
93
|
-
2025-
|
94
|
-
2025-
|
95
|
-
2025-
|
96
|
-
2025-
|
97
|
-
2025-
|
98
|
-
2025-
|
99
|
-
2025-
|
100
|
-
2025-
|
101
|
-
2025-
|
102
|
-
2025-
|
103
|
-
2025-
|
104
|
-
2025-
|
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. メソッド一覧
|
@@ -576,5 +577,5 @@ debugtrace.ymlには以下のプロパティを指定できます。
|
|
576
577
|
|
577
578
|
[MIT ライセンス(MIT)](LICENSE.txt)
|
578
579
|
|
579
|
-
_
|
580
|
+
_© 2025 Masato Kokubo_
|
580
581
|
|
data/examples/readme-example.rb
CHANGED
@@ -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.
|
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)
|
@@ -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
|
data/lib/debugtrace/version.rb
CHANGED
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'
|
@@ -566,13 +567,10 @@ module DebugTrace
|
|
566
567
|
end
|
567
568
|
|
568
569
|
# append print suffix
|
569
|
-
location = caller_locations(3, 3)[0]
|
570
|
-
name = !location.nil? ? location.base_label : ''
|
571
|
-
filename = !location.nil? ? File.basename(location.absolute_path) : ''
|
572
|
-
lineno = !location.nil? ? location.lineno : 0
|
570
|
+
location = Location.new(caller_locations(3, 3)[0])
|
573
571
|
|
574
572
|
@@last_log_buff.no_break_append(
|
575
|
-
format(@@config.print_suffix_format, name, filename, lineno)
|
573
|
+
format(@@config.print_suffix_format, location.name, location.filename, location.lineno)
|
576
574
|
)
|
577
575
|
|
578
576
|
@@last_log_buff.line_feed
|
@@ -596,16 +594,8 @@ module DebugTrace
|
|
596
594
|
return unless @@config.enabled?
|
597
595
|
|
598
596
|
state = current_state
|
599
|
-
|
600
|
-
|
601
|
-
name = !location.nil? ? location.base_label : ''
|
602
|
-
filename = !location.nil? ? File.basename(location.absolute_path) : ''
|
603
|
-
lineno = !location.nil? ? location.lineno : 0
|
604
|
-
|
605
|
-
parent_location = caller_locations(4, 4)[0]
|
606
|
-
parent_name = !parent_location.nil? ? parent_location.base_label : ''
|
607
|
-
parent_filename = !parent_location.nil? ? File.basename(parent_location.absolute_path) : ''
|
608
|
-
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])
|
609
599
|
|
610
600
|
indent_string = get_indent_string(state.nest_level, 0)
|
611
601
|
if state.nest_level < state.previous_nest_level || @@last_log_buff.multi_lines?
|
@@ -614,7 +604,9 @@ module DebugTrace
|
|
614
604
|
|
615
605
|
@@last_log_buff = LogBuffer.new(@@config.data_output_width)
|
616
606
|
@@last_log_buff.no_break_append(
|
617
|
-
format(@@config.enter_format,
|
607
|
+
format(@@config.enter_format,
|
608
|
+
location.name, location.filename, location.lineno,
|
609
|
+
parent_location.name, parent_location.filename, parent_location.lineno)
|
618
610
|
)
|
619
611
|
@@last_log_buff.line_feed
|
620
612
|
@@logger.print(indent_string + @@last_log_buff.lines[0].log)
|
@@ -633,11 +625,7 @@ module DebugTrace
|
|
633
625
|
return return_value unless @@config.enabled?
|
634
626
|
|
635
627
|
state = current_state
|
636
|
-
|
637
|
-
location = caller_locations(3, 3)[0]
|
638
|
-
name = location.base_label
|
639
|
-
filename = File.basename(location.absolute_path)
|
640
|
-
lineno = location.lineno
|
628
|
+
location = Location.new(caller_locations(3, 3)[0])
|
641
629
|
|
642
630
|
if @@last_log_buff.multi_lines?
|
643
631
|
@@logger.print(get_indent_string(state.nest_level, 0)) # Empty Line
|
@@ -647,7 +635,7 @@ module DebugTrace
|
|
647
635
|
|
648
636
|
@@last_log_buff = LogBuffer.new(@@config.data_output_width)
|
649
637
|
@@last_log_buff.no_break_append(
|
650
|
-
format(@@config.leave_format, name, filename, lineno, time)
|
638
|
+
format(@@config.leave_format, location.name, location.filename, location.lineno, time)
|
651
639
|
)
|
652
640
|
@@last_log_buff.line_feed
|
653
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.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
|