1
1
# TraceLocation
2
2
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file ` lib/trace_location ` . To experiment with that code, run ` bin/console ` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ TraceLocation gem provides logs a tracing result of ` :call ` and ` :return ` . It's useful for reading the huge codes (e.g. Ruby on Rails) and tracing its process.
6
4
7
5
## Installation
8
6
@@ -22,17 +20,76 @@ Or install it yourself as:
22
20
23
21
## Usage
24
22
25
- TODO: Write usage instructions here
26
-
27
- ## Development
23
+ You just surround the code which you want to track the process.
24
+ For example, when you want to track the process of Rails application request/response:
28
25
29
- After checking out the repo, run ` bin/setup ` to install dependencies. Then, run ` rake spec ` to run the tests. You can also run ` bin/console ` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run ` bundle exec rake install ` . To release a new version, update the version number in ` version.rb ` , and then run ` bundle exec rake release ` , which will create a git tag for the version, push git commits and tags, and push the ` .gem ` file to [ rubygems.org] ( https://rubygems.org ) .
26
+ ```
27
+ % bin/rails c
28
+ Running via Spring preloader in process 40741
29
+ Loading development environment (Rails 5.2.3)
30
+ irb(main):001:0> env = Rack::MockRequest.env_for('http://localhost:3000/api/stories')
31
+ irb(main):002:0> TraceLocation.trace { status, headers, body = Rails.application.call(env) }
32
+ Created at /path/to/sampleapp/log/trace_location-2019050105051556706139.log
33
+ => true
34
+ ```
32
35
33
- ## Contributing
36
+ Then you can get a log like this:
34
37
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/yhirano55/trace_location .
38
+ ```
39
+ Logged by TraceLocation gem at 2019-05-01 05:22:19 -0500
40
+ https://github.com/yhirano55/trace_location
41
+
42
+ [Tracing events] C: Call, R: Return
43
+
44
+ R <internal:prelude>:138#enable
45
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails.rb:39#application
46
+ R /vendor/bundle/gems/railties-5.2.3/lib/rails.rb:41#application
47
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:522#call
48
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails/application.rb:607#build_request
49
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:705#build_request
50
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails/application.rb:247#env_config
51
+ R /vendor/bundle/gems/railties-5.2.3/lib/rails/application.rb:275#env_config
52
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:59#initialize
53
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:40#initialize
54
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/url.rb:186#initialize
55
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/filter_parameters.rb:34#initialize
56
+ R /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/filter_parameters.rb:39#initialize
57
+ R /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/url.rb:190#initialize
58
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:43#initialize
59
+ R /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:67#initialize
60
+ C /vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:534#routes
61
+ R /vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:538#routes
62
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:142#routes=
63
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:68#set_header
64
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:70#set_header
65
+ R /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:144#routes=
66
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:129#script_name
67
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:52#get_header
68
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:54#get_header
69
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:129#script_name
70
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:150#engine_script_name=
71
+ C /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/http/request.rb:138#routes
72
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:52#get_header
73
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/request.rb:54#get_header
74
+ ..................
75
+ (an omission)
76
+ ..................
77
+ R /vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/static.rb:128#call
78
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:9#respond_to?
79
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:9#respond_to?
80
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:9#respond_to?
81
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:9#respond_to?
82
+ C /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:9#respond_to?
83
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:15#respond_to?
84
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:15#respond_to?
85
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:15#respond_to?
86
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:15#respond_to?
87
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/body_proxy.rb:15#respond_to?
88
+ R /vendor/bundle/gems/rack-2.0.7/lib/rack/sendfile.rb:140#call
89
+ R /vendor/bundle/gems/railties-5.2.3/lib/rails/engine.rb:525#call
90
+
91
+ Result: [200, {"Content-Type"=>"application/json; charset=utf-8", "ETag"=>"W/\"42334f8fba25471804e2cfa66fa989a7\"", "Cache-Control"=>"max-age=0, private, must-revalidate", "X-Request-Id"=>"f30153ff-3446-453a-a547-34c4b3766bfc", "X-Runtime"=>"0.455604"}, #<Rack::BodyProxy:0x00007f957960a430 @body=#<Rack::BodyProxy:0x00007f957f1c1f08 @body=#<Rack::BodyProxy:0x00007f957f1a8c10 @body=#<Rack::BodyProxy:0x00007f957f198040 @body=#<Rack::BodyProxy:0x00007f957f17bf58 @body=["[{\"id\":1,\"title\":\"The boy who cried 'wolf!'\",\"parentId\":1},{\"id\":2,\"title\":\"story 2\",\"parentId\":4},{\"id\":3,\"title\":\"story 3\",\"parentId\":null},{\"id\":4,\"title\":\"story 4\",\"parentId\":null},{\"id\":5,\"title\":\"story 1\",\"parentId\":null},{\"id\":6,\"title\":\"story 6\",\"parentId\":null},{\"id\":7,\"title\":\"story 7\",\"parentId\":null},{\"id\":8,\"title\":\"story 8\",\"parentId\":null},{\"id\":9,\"title\":\"story 9\",\"parentId\":null},{\"id\":10,\"title\":\"story 10\",\"parentId\":null},{\"id\":11,\"title\":\"story 11\",\"parentId\":null},{\"id\":12,\"title\":\"story 12\",\"parentId\":null},{\"id\":13,\"title\":\"story 13\",\"parentId\":null}]"], @block=#<Proc:0x00007f957f17ae78@/path/to/sampleapp/vendor/bundle/gems/rack-2.0.7/lib/rack/etag.rb:30>, @closed=false>, @block=#<Proc:0x00007f957f1a2d38@/path/to/sampleapp/vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:15>, @closed=false>, @block=#<Proc:0x00007f957f1b3728@/path/to/sampleapp/vendor/bundle/gems/railties-5.2.3/lib/rails/rack/logger.rb:39>, @closed=false>, @block=#<Proc:0x00007f957f1c07c0@/path/to/sampleapp/vendor/bundle/gems/activesupport-5.2.3/lib/active_support/cache/strategy/local_cache_middleware.rb:30>, @closed=false>, @block=#<Proc:0x00007f95796096c0@/path/to/sampleapp/vendor/bundle/gems/actionpack-5.2.3/lib/action_dispatch/middleware/executor.rb:15>, @closed=false>]
92
+ ```
36
93
37
94
## License
38
95
0 commit comments