gc_tracer 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/gc_tracer/version.rb +1 -1
- data/lib/rack/gc_tracer.rb +29 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edb39709fa72ef674a41795d9a73c87ea8627d12
|
4
|
+
data.tar.gz: b6a6305de8e33f50ab78877f6cb5b0e7eef60e68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 33183d39bbf2a0a1a4648334d5d101ccc0101b211e555f662c840a78cfb561bfc173397c0e111922911540b6f6fa2fc4fa35105e4e06fbdc8bea03f24809bce1
|
7
|
+
data.tar.gz: 21c11cd481b69ba3aceacb08f434d7b3bf3158390cb22bda7a5aeac29a033ce02bd3eb762d6469b4104c5ac68fa790f50ceeecb006ce274778d739afd22a13ae
|
data/README.md
CHANGED
@@ -166,19 +166,24 @@ require 'rack'
|
|
166
166
|
require 'sinatra'
|
167
167
|
require 'rack/gc_tracer'
|
168
168
|
|
169
|
-
use Rack::GCTracerMiddleware, view_page_path: '/gc_tracer'
|
169
|
+
use Rack::GCTracerMiddleware, view_page_path: '/gc_tracer', filename: 'logging_file_name'
|
170
170
|
|
171
171
|
get '/' do
|
172
172
|
'foo'
|
173
173
|
end
|
174
174
|
```
|
175
175
|
|
176
|
+
In this case, you can access two pages.
|
177
|
+
|
178
|
+
* http://host/gc_tracer - HTML table style page
|
179
|
+
* http://host/gc_tracer/text - plain text page
|
180
|
+
|
176
181
|
You can pass two options.
|
177
182
|
|
178
|
-
*
|
183
|
+
* filename: File name of GC Tracer log
|
179
184
|
* view_page_path: You can view GC tracer log with this path *if logging_filename is given*. You should not use this option on production.
|
180
185
|
|
181
|
-
And also you can pass all options
|
186
|
+
And also you can pass all options of `GC::Tracer.start_logging`.
|
182
187
|
|
183
188
|
## Contributing
|
184
189
|
|
data/lib/gc_tracer/version.rb
CHANGED
data/lib/rack/gc_tracer.rb
CHANGED
@@ -6,18 +6,42 @@ require 'gc_tracer'
|
|
6
6
|
|
7
7
|
module Rack
|
8
8
|
class GCTracerMiddleware
|
9
|
-
def initialize app, view_page_path: nil,
|
9
|
+
def initialize app, view_page_path: nil, filename: nil, **kw
|
10
10
|
@app = app
|
11
11
|
@view_page_path = view_page_path
|
12
|
-
@logging_filename =
|
13
|
-
|
12
|
+
@logging_filename = filename || GC::Tracer.env_logging_filename
|
13
|
+
|
14
|
+
if @logging_filename && view_page_path
|
15
|
+
@view_page_pattern = /\A#{view_page_path}/
|
16
|
+
else
|
17
|
+
@view_page_pattern = nil
|
18
|
+
end
|
19
|
+
|
14
20
|
GC::Tracer.start_logging @logging_filename, custom_fields: %i(accesses), **kw
|
15
21
|
end
|
16
22
|
|
23
|
+
def make_page
|
24
|
+
header = data = nil
|
25
|
+
open(@logging_filename){|f|
|
26
|
+
header = f.gets
|
27
|
+
data = f.readlines
|
28
|
+
}
|
29
|
+
headers = "<tr>" + header.split(/\s+/).map{|e| "<th>#{e}</th>"}.join("\n") + "</tr>"
|
30
|
+
data = data.map{|line|
|
31
|
+
"<tr>" + line.split(/\s+/).map{|e| "<td>#{e}</td>"}.join + "</td>"
|
32
|
+
}.join("\n")
|
33
|
+
"<table>#{headers}\n#{data}</table>"
|
34
|
+
end
|
35
|
+
|
17
36
|
def call env
|
18
|
-
if @
|
37
|
+
if @view_page_pattern && @view_page_pattern =~ env["PATH_INFO"]
|
19
38
|
GC::Tracer.flush_logging
|
20
|
-
[
|
39
|
+
p env["PATH_INFO"]
|
40
|
+
if env["PATH_INFO"] == @view_page_path + "/text"
|
41
|
+
[200, {"Content-Type" => "text/plain"}, [open(@logging_filename).read]]
|
42
|
+
else
|
43
|
+
[200, {"Content-Type" => "text/html"}, [make_page]]
|
44
|
+
end
|
21
45
|
else
|
22
46
|
GC::Tracer.custom_field_increment(0)
|
23
47
|
@app.call(env)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gc_tracer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Koichi Sasada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|