tracia 0.2.9 → 0.2.16

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ac587bcc0c01258f1220731adda063b6c83a7f66e87fe51da334286e7f629c7a
4
- data.tar.gz: 972cfa5242cb2570aa6e9614fc30fa43937cf8c23390af260c0685b57573d094
3
+ metadata.gz: b8d300497cc3f967c73f989925819a051d16ab7a9948b38068d37042aef2058d
4
+ data.tar.gz: 279e441cef317891df0030997cf88078292bee6544975635abf519d4cfc0f006
5
5
  SHA512:
6
- metadata.gz: d7631de3f1aaa6cae27892e120ba4eadb9318c04f4461c8697141278642d4fd18253fc8b11abb26408a306d683c0e71f8c356f03dd8c862273fdbaf4a2c6ac36
7
- data.tar.gz: 6410a901a160249b4dab2eebe147f7a517e2ffc5da81a99d097e12d031a59e631a3b5c4ec44dfbb6566cc34d416768725cf1dd7aa09db7713e7c72719f1a7e67
6
+ metadata.gz: 194d257a120813ad1a7a676f12652bb1cd5ff25a226314217d7c0657fe526a2100ebe18b095561371d8dbd9fc1cdcb601cff38674dd89a2eb1c614cf9d2269f3
7
+ data.tar.gz: 7c4d3c5b3cb21bf6299f1358d1fd40ff450fcb073043de436f43332801e48712820a32f2bb9657cf472f99ad7d2307b5be5aaac9d1e8f0bd7ea84fc9eebf7a5d
data/README.md CHANGED
@@ -76,6 +76,16 @@ Tracia.start(logger: MyLogger.new(db_connection)) do
76
76
  end
77
77
  ```
78
78
 
79
+ ### Log `raise`
80
+
81
+ By default, Tracia log `raise` event via `TracePoint`. You can disable this feature by `trace_point: false`
82
+
83
+ ```ruby
84
+ Tracia.start(trace_point: false) do
85
+ # ...
86
+ end
87
+ ```
88
+
79
89
  ## Development
80
90
 
81
91
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -0,0 +1,9 @@
1
+ class Tracia
2
+ class FakeTracePoint
3
+ def enable
4
+ end
5
+
6
+ def disable
7
+ end
8
+ end
9
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Tracia
4
- VERSION = "0.2.9"
4
+ VERSION = "0.2.16"
5
5
  end
data/lib/tracia.rb CHANGED
@@ -4,6 +4,7 @@ require "tracia/version"
4
4
  require "tracia/gem_paths"
5
5
  require "tracia/frame"
6
6
  require "tracia/default_logger"
7
+ require "tracia/fake_trace_point"
7
8
 
8
9
  require "binding_of_callers"
9
10
 
@@ -52,12 +53,17 @@ class Tracia
52
53
  @backtraces = []
53
54
  @level = 0
54
55
 
55
- enable_trace_point
56
+ enable_trace_point(opt[:trace_point])
56
57
  end
57
58
 
58
- def enable_trace_point
59
+ def enable_trace_point(trace_point_opt)
60
+ return @trace_point = FakeTracePoint.new if trace_point_opt == false
61
+
59
62
  current_thread = Thread.current
60
63
  @trace_point = TracePoint.new(:raise) do |point|
64
+ if Proc === trace_point_opt
65
+ next if trace_point_opt.call(point, self) == false
66
+ end
61
67
  bd = point.binding
62
68
  next unless current_thread == bd.eval('Thread.current')
63
69
  backtrace = bd.eval("binding.partial_callers(-#{depth})")
@@ -164,22 +170,17 @@ class Tracia
164
170
  @frames_to_reject.any?{ |rj| rj =~ raw_frame.file }
165
171
  end
166
172
 
173
+ FAKE_METHOD = Struct.new(:source_location).new([nil, 0])
174
+
167
175
  def convert_to_frames(callers)
168
176
  callers.map! do |c|
169
177
  _binding = c._binding
178
+ iseq = _binding.instance_variable_get(:@iseq)
170
179
  klass = c.klass
171
180
  call_symbol = c.call_symbol
172
181
  frame_env = c.frame_env
173
182
 
174
- source_location =
175
- if _binding.frame_type == :method
176
- meth = call_symbol == INSTANCE_METHOD_SHARP ? klass.instance_method(frame_env) : klass.method(frame_env)
177
- meth.source_location
178
- else
179
- _binding.source_location
180
- end
181
-
182
- Frame.new(klass, call_symbol, frame_env, source_location[0], source_location[1])
183
+ Frame.new(klass, call_symbol, frame_env, iseq.path, iseq.first_lineno)
183
184
  end
184
185
 
185
186
  callers
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - ken
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-02 00:00:00.000000000 Z
11
+ date: 2022-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -80,6 +80,7 @@ files:
80
80
  - Rakefile
81
81
  - lib/tracia.rb
82
82
  - lib/tracia/default_logger.rb
83
+ - lib/tracia/fake_trace_point.rb
83
84
  - lib/tracia/frame.rb
84
85
  - lib/tracia/gem_paths.rb
85
86
  - lib/tracia/version.rb