debugtrace 1.1.0 → 1.1.2

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: fa74406233753b57eb94f0f05e67ec9e9818014ccaa6fda15a93ff65bd406be4
4
- data.tar.gz: 131f249a1bddfd25c5be1d7c87a140c8b77540863ea8b84a6b9a5205f3bb57db
3
+ metadata.gz: d0fd5212be7e014267a9795f6de78a3cc53f3c04d9f7214cddc798c36be0e746
4
+ data.tar.gz: d21287e1f2d00d7fb65b3b486aa7a7c4a115c9f795b5efad4f3b74a6b69fa1fb
5
5
  SHA512:
6
- metadata.gz: 1ff6920733cfc9e0f51d3fe0b532cb5389ca419cf6f950c3bd4083a6202e4673cd0eb93ba67df1aaca431562dc8a36c43c67572d20fc90e0e30b0a265f18ec3c
7
- data.tar.gz: de378f10d17017256fa03c5fac2fa2709e9b0ee8775f79c7373139302baeb062584ea5534f43a3d74f4725e2ae448257aa69bd3ba6c245bd5e26a7c5b31650ba
6
+ metadata.gz: 6b737dacef0b6a82c8acd25cd6117432313e931d2181f8c1be1557534e9e97e311dec5ecbd10eedd85da914dacb27805abf660f0e790ba7dad1c7dfa7c58260a
7
+ data.tar.gz: 64e246128f381dd3e8058d524b3878e0017f9db4d99b42deed5fb8c9aeb06d3a4216a51bc7360e5e51be3fdc9bfb58317e86e8ae639359562f45d6de63a9e30f
data/CHANGELOG.md CHANGED
@@ -1,6 +1,14 @@
1
+ ## 1.1.2 - July 2, 2025
2
+
3
+ Fixed a bug that caused exceptions to be thrown by the `print` methods depending on the conditions.
4
+
5
+ ## 1.1.1 - July 1, 2025
6
+
7
+ Fixed a bug that caused exceptions to be thrown by the `enter`, `leave` and `print` methods depending on the conditions.
8
+
1
9
  ## 1.1.0 - May 25, 2025
2
10
 
3
- ### Bug fixes
11
+ ### Bug fix
4
12
 
5
13
  * Fixed a bug where line breaks were not inserted between elements when outputting `Array`, `Hash`, and `Set` using the print method.
6
14
 
data/CHANGELOG_ja.md ADDED
@@ -0,0 +1,25 @@
1
+ ## 1.1.2 - 2025/7/2
2
+
3
+ 条件によって`print`メソッドで例外がスローされるバグを修正。
4
+
5
+ ## 1.1.1 - 2025/7/1
6
+
7
+ 条件によって`enter`, `leave`, `print`メソッドで例外がスローされるバグを修正。
8
+
9
+ ## 1.1.0 - 2025/5/25
10
+
11
+ `print`メソッドで`Array`, `Hash`および`Set`を出力する場合に要素間での改行が行われないバグの修正。
12
+
13
+ #### 仕様変更
14
+
15
+ * `print`メソッドの以下のキーワード引数名を変更、また`debugtrace.yml`の同名のプロパティ名も変更
16
+ * `output_size_limit` ← `collection_limit`
17
+ * `output_length_limit` ← `string_limit` および `bytes_limit` _(統一)_
18
+
19
+ ## 1.0.1 - 2025/5/19
20
+
21
+ 環境変数 `DEBUGTRACE_CONFIG` が設定されていない場合にエラーが発生するバグを修正。
22
+
23
+ ## 1.0.0 - 2025/5/18
24
+
25
+ 最初のリリース
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
@@ -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
- _(C) 2025 Masato Kokubo_
580
+ _&copy; 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
- ## 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. メソッド一覧
@@ -576,5 +577,5 @@ debugtrace.ymlには以下のプロパティを指定できます。
576
577
 
577
578
  [MIT ライセンス(MIT)](LICENSE.txt)
578
579
 
579
- _(C) 2025 Masato Kokubo_
580
+ _&copy; 2025 Masato Kokubo_
580
581
 
@@ -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)
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DebugTrace
4
- VERSION = '1.1.0'
4
+ VERSION = '1.1.2'
5
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'
@@ -180,25 +181,29 @@ module DebugTrace
180
181
  buff.append_buffer(value_buff)
181
182
  else
182
183
  reflection = print_options.reflection || value.class.superclass == Struct
183
-
184
- to_s_string = reflection ? '' : value.to_s
185
- if reflection || to_s_string.start_with?('#<')
186
- # use reflection
187
- value_buff = LogBuffer.new(@@config.data_output_width)
188
- if @@reflected_objects.any? { |obj| value.equal?(obj) }
189
- # cyclic reference
190
- value_buff.no_break_append(@@config.circular_reference_string)
191
- elsif @@reflected_objects.length > print_options.reflection_limit
192
- # over reflection level limitation
193
- value_buff.no_break_append(@@config.limit_string)
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)
194
202
  else
195
- @@reflected_objects.push(value)
196
- value_buff = to_string_reflection(value, print_options)
197
- @@reflected_objects.pop
203
+ buff.append(to_s_string)
198
204
  end
199
- buff.append_buffer(value_buff)
200
- else
201
- buff.append(to_s_string)
205
+ rescue => e
206
+ buff.append("Raised #{e.class.to_s}: '#{e.message}'")
202
207
  end
203
208
  end
204
209
  end
@@ -566,13 +571,10 @@ module DebugTrace
566
571
  end
567
572
 
568
573
  # 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
574
+ location = Location.new(caller_locations(3, 3)[0])
573
575
 
574
576
  @@last_log_buff.no_break_append(
575
- format(@@config.print_suffix_format, name, filename, lineno)
577
+ format(@@config.print_suffix_format, location.name, location.filename, location.lineno)
576
578
  )
577
579
 
578
580
  @@last_log_buff.line_feed
@@ -596,16 +598,8 @@ module DebugTrace
596
598
  return unless @@config.enabled?
597
599
 
598
600
  state = current_state
599
-
600
- location = caller_locations(3, 3)[0]
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
601
+ location = Location.new(caller_locations(3, 3)[0])
602
+ parent_location = Location.new(caller_locations(4, 4)[0])
609
603
 
610
604
  indent_string = get_indent_string(state.nest_level, 0)
611
605
  if state.nest_level < state.previous_nest_level || @@last_log_buff.multi_lines?
@@ -614,7 +608,9 @@ module DebugTrace
614
608
 
615
609
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
616
610
  @@last_log_buff.no_break_append(
617
- format(@@config.enter_format, name, filename, lineno, parent_name, parent_filename, parent_lineno)
611
+ format(@@config.enter_format,
612
+ location.name, location.filename, location.lineno,
613
+ parent_location.name, parent_location.filename, parent_location.lineno)
618
614
  )
619
615
  @@last_log_buff.line_feed
620
616
  @@logger.print(indent_string + @@last_log_buff.lines[0].log)
@@ -633,11 +629,7 @@ module DebugTrace
633
629
  return return_value unless @@config.enabled?
634
630
 
635
631
  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
632
+ location = Location.new(caller_locations(3, 3)[0])
641
633
 
642
634
  if @@last_log_buff.multi_lines?
643
635
  @@logger.print(get_indent_string(state.nest_level, 0)) # Empty Line
@@ -647,7 +639,7 @@ module DebugTrace
647
639
 
648
640
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
649
641
  @@last_log_buff.no_break_append(
650
- format(@@config.leave_format, name, filename, lineno, time)
642
+ format(@@config.leave_format, location.name, location.filename, location.lineno, time)
651
643
  )
652
644
  @@last_log_buff.line_feed
653
645
  @@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.0
4
+ version: 1.1.2
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