tracia 0.2.0 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/tracia/default_logger.rb +3 -0
- data/lib/tracia/frame.rb +3 -3
- data/lib/tracia/version.rb +1 -1
- data/lib/tracia.rb +3 -3
- metadata +9 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34b3cdfc3aa852818abd808ccb2f108d3999d52ee35168856e2255849d2a5087
|
4
|
+
data.tar.gz: 5c54033d24d401aeb28b174c3d05b4762850cd72526c594b2b2b108c639f2452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c36aea77f0cdc14839d69d71d20844c73f11dc5941138b50cb3c87c1d78da95176d18c5f187846980ffcef49467c55fe91a4a85ed3a329b7a4ee7ab3cbfdfa
|
7
|
+
data.tar.gz: ac94cda876214cc85709a8e8f8a4e834a1b3cb601b08befc38e242bd27e1d35591926552d5943a16d6eb55642e771a19017950905b91c4c1920d24d299fb3414
|
data/README.md
CHANGED
@@ -42,7 +42,17 @@ end
|
|
42
42
|
|
43
43
|
### Custom Logger
|
44
44
|
|
45
|
-
|
45
|
+
By default, Tracia writes result to STDOUT, you can set it somewhere else
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
file = File.new('/path/to/log.txt', 'w+')
|
49
|
+
|
50
|
+
Tracia.start(logger: Tracia::DefaultLogger.new(out: file)) do
|
51
|
+
# ...
|
52
|
+
end
|
53
|
+
```
|
54
|
+
|
55
|
+
Or you can make a logger class which responds to `call`
|
46
56
|
|
47
57
|
```ruby
|
48
58
|
class MyLogger
|
@@ -50,6 +60,7 @@ class MyLogger
|
|
50
60
|
@database = database
|
51
61
|
end
|
52
62
|
|
63
|
+
# callback method for Tracia
|
53
64
|
def call(root)
|
54
65
|
# ...
|
55
66
|
@database.insert(root)
|
@@ -57,7 +68,7 @@ class MyLogger
|
|
57
68
|
end
|
58
69
|
```
|
59
70
|
|
60
|
-
|
71
|
+
Then pass that logger to Tracia
|
61
72
|
|
62
73
|
```ruby
|
63
74
|
Tracia.start(logger: MyLogger.new(db_connection)) do
|
data/lib/tracia/frame.rb
CHANGED
@@ -4,14 +4,14 @@ class Tracia
|
|
4
4
|
class Frame
|
5
5
|
include TreeGraph
|
6
6
|
|
7
|
-
attr_reader :klass, :call_sym, :method_name, :children, :file
|
7
|
+
attr_reader :klass, :call_sym, :method_name, :children, :file, :lineno
|
8
8
|
|
9
9
|
def initialize(klass, call_sym, method_name, file, lineno)
|
10
|
-
@file = file
|
11
|
-
@lineno = lineno
|
12
10
|
@klass = klass
|
13
11
|
@call_sym = call_sym
|
14
12
|
@method_name = method_name
|
13
|
+
@file = file
|
14
|
+
@lineno = lineno
|
15
15
|
@children = []
|
16
16
|
end
|
17
17
|
|
data/lib/tracia/version.rb
CHANGED
data/lib/tracia.rb
CHANGED
@@ -18,7 +18,7 @@ class Tracia
|
|
18
18
|
def start(**opt)
|
19
19
|
trc = (Thread.current[:_tracia_] ||= new(**opt))
|
20
20
|
trc.level += 1
|
21
|
-
trc.depth = binding.frame_count
|
21
|
+
trc.depth = binding.frame_count + 1
|
22
22
|
yield
|
23
23
|
rescue StandardError => e
|
24
24
|
trc.error = e
|
@@ -36,7 +36,7 @@ class Tracia
|
|
36
36
|
trc = Thread.current[:_tracia_]
|
37
37
|
return unless trc
|
38
38
|
|
39
|
-
backtrace = binding.
|
39
|
+
backtrace = binding.partial_callers(-trc.depth)
|
40
40
|
backtrace.reverse!
|
41
41
|
backtrace.pop
|
42
42
|
trc.add(backtrace, info)
|
@@ -59,7 +59,7 @@ class Tracia
|
|
59
59
|
@trace_point = TracePoint.new(:raise) do |point|
|
60
60
|
bd = point.binding
|
61
61
|
next unless current_thread == bd.eval('Thread.current')
|
62
|
-
backtrace = bd.eval("binding.
|
62
|
+
backtrace = bd.eval("binding.partial_callers(-#{depth})")
|
63
63
|
raiser = backtrace[0]
|
64
64
|
next if raiser.klass == Tracia && raiser.frame_env == 'rescue in start'
|
65
65
|
backtrace.reverse!
|
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.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ken
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|
@@ -44,15 +44,15 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.2.
|
47
|
+
version: 0.2.3
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.2.
|
55
|
-
description:
|
54
|
+
version: 0.2.3
|
55
|
+
description:
|
56
56
|
email:
|
57
57
|
- block24block@gmail.com
|
58
58
|
executables: []
|
@@ -74,7 +74,7 @@ homepage: https://github.com/turnon/tracia
|
|
74
74
|
licenses:
|
75
75
|
- MIT
|
76
76
|
metadata: {}
|
77
|
-
post_install_message:
|
77
|
+
post_install_message:
|
78
78
|
rdoc_options: []
|
79
79
|
require_paths:
|
80
80
|
- lib
|
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
92
|
+
rubygems_version: 3.3.7
|
93
|
+
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: bottum-up tracing
|
96
96
|
test_files: []
|