debugtrace 1.1.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0fd5212be7e014267a9795f6de78a3cc53f3c04d9f7214cddc798c36be0e746
4
- data.tar.gz: d21287e1f2d00d7fb65b3b486aa7a7c4a115c9f795b5efad4f3b74a6b69fa1fb
3
+ metadata.gz: 04bce05e2d9f97e7a4c0e1aa1e4b097a49cd4669615ca56e69ab197d2f2a494b
4
+ data.tar.gz: 4a6ab354ae3515f2167dd6779027f89fc49e49710a17b9d842570d8ec92a13f1
5
5
  SHA512:
6
- metadata.gz: 6b737dacef0b6a82c8acd25cd6117432313e931d2181f8c1be1557534e9e97e311dec5ecbd10eedd85da914dacb27805abf660f0e790ba7dad1c7dfa7c58260a
7
- data.tar.gz: 64e246128f381dd3e8058d524b3878e0017f9db4d99b42deed5fb8c9aeb06d3a4216a51bc7360e5e51be3fdc9bfb58317e86e8ae639359562f45d6de63a9e30f
6
+ metadata.gz: c46e1e92e14d5f42f22b208b39911ff6c4f651fa15f4f5be89ace408f6e0448e2a931f1e0983d82d1a831b03f5167cbe2ccd369bf8eed6014cecbb202acdf8c8
7
+ data.tar.gz: 930dd3f482134f6e39dfc96e64f73c23f8630ac32241aa725e0ebc772c02ccae29f3911f850da5c31e02dac2a87a61af2591a4f8f414d94e09eaf3f3e138f33d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
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
+
1
6
  ## 1.1.2 - July 2, 2025
2
7
 
3
8
  Fixed a bug that caused exceptions to be thrown by the `print` methods depending on the conditions.
data/CHANGELOG_ja.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.2.0 - 2025/7/5
2
+
3
+ * ソースファイル名の出力をカレントディレクトリからの相対パスに変更。
4
+ * メソッド名の出力にクラス名を追加。
5
+
1
6
  ## 1.1.2 - 2025/7/2
2
7
 
3
8
  条件によって`print`メソッドで例外がスローされるバグを修正。
data/README.md CHANGED
@@ -77,32 +77,32 @@ func1
77
77
  ```
78
78
 
79
79
  ```log
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)
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-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)
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. メソッド一覧
@@ -5,7 +5,7 @@
5
5
  # Contains source location information.
6
6
  class Location
7
7
  attr_reader :name
8
- attr_reader :filename
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
- @filename = 'unknown'
17
+ @path = 'unknown'
18
18
  @lineno = 0
19
19
  else
20
- @name = caller_location.base_label
21
- path = caller_location.absolute_path || caller_location.path || 'unknown'
22
- @filename = File.basename(path)
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}, filename: #{@filename}, lineno: #{@lineno}"
33
+ return "(Location){name: #{@name}, path: #{@path}, lineno: #{@lineno}"
32
34
  end
33
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DebugTrace
4
- VERSION = '1.1.2'
4
+ VERSION = '1.2.0'
5
5
  end
data/lib/debugtrace.rb CHANGED
@@ -574,7 +574,7 @@ module DebugTrace
574
574
  location = Location.new(caller_locations(3, 3)[0])
575
575
 
576
576
  @@last_log_buff.no_break_append(
577
- format(@@config.print_suffix_format, location.name, location.filename, location.lineno)
577
+ format(@@config.print_suffix_format, location.name, location.path, location.lineno)
578
578
  )
579
579
 
580
580
  @@last_log_buff.line_feed
@@ -609,14 +609,15 @@ module DebugTrace
609
609
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
610
610
  @@last_log_buff.no_break_append(
611
611
  format(@@config.enter_format,
612
- location.name, location.filename, location.lineno,
613
- parent_location.name, parent_location.filename, parent_location.lineno)
612
+ location.name, location.path, location.lineno,
613
+ parent_location.name, parent_location.path, parent_location.lineno)
614
614
  )
615
615
  @@last_log_buff.line_feed
616
616
  @@logger.print(indent_string + @@last_log_buff.lines[0].log)
617
617
 
618
618
  state.up_nest
619
619
  end
620
+ return nil
620
621
  end
621
622
 
622
623
  # Prints the end of the method.
@@ -639,12 +640,12 @@ module DebugTrace
639
640
 
640
641
  @@last_log_buff = LogBuffer.new(@@config.data_output_width)
641
642
  @@last_log_buff.no_break_append(
642
- format(@@config.leave_format, location.name, location.filename, location.lineno, time)
643
+ format(@@config.leave_format, location.name, location.path, location.lineno, time)
643
644
  )
644
645
  @@last_log_buff.line_feed
645
646
  @@logger.print(get_indent_string(state.nest_level, 0) + @@last_log_buff.lines[0].log)
646
- return return_value
647
647
  end
648
+ return return_value
648
649
  end
649
650
 
650
651
  # Returns the last print string.
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.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masato Kokubo