debugtrace 0.1.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.
data/lib/temp.rb ADDED
@@ -0,0 +1,74 @@
1
+ class DebugTrace
2
+ # Outputs an entering log when initializing and outputs a leaving log when deleting.
3
+ #
4
+ # 初期化時に進入ログを出力し、削除時に退出ログを出力します。
5
+
6
+ attr_accessor :name, :filename, :lineno
7
+
8
+ def initialize(invoker)
9
+ return unless @@config.is_enabled
10
+
11
+ Mutex.new.synchronize do
12
+ print_start
13
+
14
+ state = current_state
15
+ if invoker.nil?
16
+ @name = ''
17
+ else
18
+ @name = invoker.class.name
19
+ if @name == 'Class'
20
+ @name = invoker.to_s
21
+ end
22
+ @name += '.'
23
+ end
24
+
25
+ # frame_summary = get_frame_summary(4)
26
+ location = caller_locations(1, 1)[0]
27
+ @name += location.base_label
28
+ @filename = File.basename(location.absolute_path)
29
+ @lineno = location.lineno
30
+
31
+ # parent_frame_summary = get_frame_summary(5)
32
+ parent_location = caller_locations(2, 2)[0]
33
+ parent_filename = File.basename(parent_location.absolute_path)
34
+ parent_lineno = parent_location.lineno
35
+
36
+ indent_string = get_indent_string(state.nest_level, 0)
37
+ if state.nest_level < state.previous_nest_level || _last_print_buff.is_multi_lines
38
+ _logger.print(indent_string) # Empty Line
39
+ end
40
+
41
+ _last_print_buff = LogBuffer.new(@@config.maximum_data_output_width)
42
+ _last_print_buff.no_break_append(
43
+ @@config.enter_format % [@name, @filename, @lineno, parent_filename, parent_lineno]
44
+ )
45
+ _last_print_buff.line_feed
46
+ _logger.print(indent_string + _last_print_buff.lines[0][1])
47
+
48
+ state.up_nest
49
+ end
50
+ end
51
+
52
+ def finalize
53
+ return unless @@config.is_enabled
54
+
55
+ Mutex.new.synchronize do
56
+ print_start
57
+
58
+ state = current_state
59
+
60
+ if _last_print_buff.is_multi_lines
61
+ _logger.print(get_indent_string(state.nest_level, 0)) # Empty Line
62
+ end
63
+
64
+ time = Time.now.utc - state.down_nest
65
+
66
+ _last_print_buff = LogBuffer.new(@@config.maximum_data_output_width)
67
+ _last_print_buff.no_break_append(
68
+ @@config.leave_format % [@name, @filename, @lineno, time]
69
+ )
70
+ _last_print_buff.line_feed
71
+ _logger.print(get_indent_string(state.nest_level, 0) + _last_print_buff.lines[0][1])
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ module DebugTrace
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,60 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: debugtrace
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masato Kokubo
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-04-13 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Insert DebugTrace.enter and Debug.leave at the beginning and end of the
13
+ function you want to debug, and Debug.print('foo', foo) if there are any variables
14
+ you want to display.
15
+ email:
16
+ - masatokokubo@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".rubocop.yml"
22
+ - CHANGELOG.md
23
+ - LICENSE
24
+ - README.md
25
+ - Rakefile
26
+ - lib/debugtrace.rb
27
+ - lib/debugtrace/common.rb
28
+ - lib/debugtrace/config.rb
29
+ - lib/debugtrace/log_buffer.rb
30
+ - lib/debugtrace/loggers.rb
31
+ - lib/debugtrace/print_options.rb
32
+ - lib/debugtrace/state.rb
33
+ - lib/debugtrace/version.rb
34
+ - lib/temp.rb
35
+ - sig/debugtrace.rbs
36
+ homepage: https://github.com/MasatoKokubo/DebugTrace-rb
37
+ licenses:
38
+ - MIT
39
+ metadata:
40
+ homepage_uri: https://github.com/MasatoKokubo/DebugTrace-rb
41
+ source_code_uri: https://github.com/MasatoKokubo/DebugTrace-rb
42
+ changelog_uri: https://github.com/MasatoKokubo/DebugTrace-rb
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.1.0
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubygems_version: 3.6.6
58
+ specification_version: 4
59
+ summary: DebugTrace-rb is a library that helps debug ruby programs.
60
+ test_files: []