mongo_request_logger 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/.gitignore +17 -0
- data/.travis.yml +11 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +28 -0
- data/README.md +90 -0
- data/Rakefile +1 -0
- data/config.ru +11 -0
- data/lib/mongo_request_logger/adapters/base.rb +51 -0
- data/lib/mongo_request_logger/adapters/mongo.rb +89 -0
- data/lib/mongo_request_logger/adapters/moped.rb +94 -0
- data/lib/mongo_request_logger/backtrace_cleaner.rb +11 -0
- data/lib/mongo_request_logger/config.rb +109 -0
- data/lib/mongo_request_logger/ext/buffered_logger.rb +6 -0
- data/lib/mongo_request_logger/ext/logger.rb +6 -0
- data/lib/mongo_request_logger/log_message.rb +170 -0
- data/lib/mongo_request_logger/logged_job.rb +63 -0
- data/lib/mongo_request_logger/logger.rb +122 -0
- data/lib/mongo_request_logger/logger_extensions.rb +34 -0
- data/lib/mongo_request_logger/rack.rb +63 -0
- data/lib/mongo_request_logger/railtie.rb +57 -0
- data/lib/mongo_request_logger/search_terms.rb +59 -0
- data/lib/mongo_request_logger/version.rb +3 -0
- data/lib/mongo_request_logger/viewer.rb +212 -0
- data/lib/mongo_request_logger.rb +16 -0
- data/mongo_request_logger.gemspec +24 -0
- data/public/css/bootstrap-responsive.css +815 -0
- data/public/css/bootstrap-responsive.min.css +9 -0
- data/public/css/bootstrap.css +4983 -0
- data/public/css/bootstrap.min.css +9 -0
- data/public/img/flags/ad.png +0 -0
- data/public/img/flags/ae.png +0 -0
- data/public/img/flags/af.png +0 -0
- data/public/img/flags/ag.png +0 -0
- data/public/img/flags/ai.png +0 -0
- data/public/img/flags/al.png +0 -0
- data/public/img/flags/am.png +0 -0
- data/public/img/flags/an.png +0 -0
- data/public/img/flags/ao.png +0 -0
- data/public/img/flags/ar.png +0 -0
- data/public/img/flags/as.png +0 -0
- data/public/img/flags/at.png +0 -0
- data/public/img/flags/au.png +0 -0
- data/public/img/flags/aw.png +0 -0
- data/public/img/flags/ax.png +0 -0
- data/public/img/flags/az.png +0 -0
- data/public/img/flags/ba.png +0 -0
- data/public/img/flags/bb.png +0 -0
- data/public/img/flags/bd.png +0 -0
- data/public/img/flags/be.png +0 -0
- data/public/img/flags/bf.png +0 -0
- data/public/img/flags/bg.png +0 -0
- data/public/img/flags/bh.png +0 -0
- data/public/img/flags/bi.png +0 -0
- data/public/img/flags/bj.png +0 -0
- data/public/img/flags/bm.png +0 -0
- data/public/img/flags/bn.png +0 -0
- data/public/img/flags/bo.png +0 -0
- data/public/img/flags/br.png +0 -0
- data/public/img/flags/bs.png +0 -0
- data/public/img/flags/bt.png +0 -0
- data/public/img/flags/bv.png +0 -0
- data/public/img/flags/bw.png +0 -0
- data/public/img/flags/by.png +0 -0
- data/public/img/flags/bz.png +0 -0
- data/public/img/flags/ca.png +0 -0
- data/public/img/flags/catalonia.png +0 -0
- data/public/img/flags/cc.png +0 -0
- data/public/img/flags/cd.png +0 -0
- data/public/img/flags/cf.png +0 -0
- data/public/img/flags/cg.png +0 -0
- data/public/img/flags/ch.png +0 -0
- data/public/img/flags/ci.png +0 -0
- data/public/img/flags/ck.png +0 -0
- data/public/img/flags/cl.png +0 -0
- data/public/img/flags/cm.png +0 -0
- data/public/img/flags/cn.png +0 -0
- data/public/img/flags/co.png +0 -0
- data/public/img/flags/cr.png +0 -0
- data/public/img/flags/cs.png +0 -0
- data/public/img/flags/cu.png +0 -0
- data/public/img/flags/cv.png +0 -0
- data/public/img/flags/cx.png +0 -0
- data/public/img/flags/cy.png +0 -0
- data/public/img/flags/cz.png +0 -0
- data/public/img/flags/de.png +0 -0
- data/public/img/flags/dj.png +0 -0
- data/public/img/flags/dk.png +0 -0
- data/public/img/flags/dm.png +0 -0
- data/public/img/flags/do.png +0 -0
- data/public/img/flags/dz.png +0 -0
- data/public/img/flags/ec.png +0 -0
- data/public/img/flags/ee.png +0 -0
- data/public/img/flags/eg.png +0 -0
- data/public/img/flags/eh.png +0 -0
- data/public/img/flags/england.png +0 -0
- data/public/img/flags/er.png +0 -0
- data/public/img/flags/es.png +0 -0
- data/public/img/flags/et.png +0 -0
- data/public/img/flags/europeanunion.png +0 -0
- data/public/img/flags/fam.png +0 -0
- data/public/img/flags/fi.png +0 -0
- data/public/img/flags/fj.png +0 -0
- data/public/img/flags/fk.png +0 -0
- data/public/img/flags/fm.png +0 -0
- data/public/img/flags/fo.png +0 -0
- data/public/img/flags/fr.png +0 -0
- data/public/img/flags/ga.png +0 -0
- data/public/img/flags/gb.png +0 -0
- data/public/img/flags/gd.png +0 -0
- data/public/img/flags/ge.png +0 -0
- data/public/img/flags/gf.png +0 -0
- data/public/img/flags/gh.png +0 -0
- data/public/img/flags/gi.png +0 -0
- data/public/img/flags/gl.png +0 -0
- data/public/img/flags/gm.png +0 -0
- data/public/img/flags/gn.png +0 -0
- data/public/img/flags/gp.png +0 -0
- data/public/img/flags/gq.png +0 -0
- data/public/img/flags/gr.png +0 -0
- data/public/img/flags/gs.png +0 -0
- data/public/img/flags/gt.png +0 -0
- data/public/img/flags/gu.png +0 -0
- data/public/img/flags/gw.png +0 -0
- data/public/img/flags/gy.png +0 -0
- data/public/img/flags/hk.png +0 -0
- data/public/img/flags/hm.png +0 -0
- data/public/img/flags/hn.png +0 -0
- data/public/img/flags/hr.png +0 -0
- data/public/img/flags/ht.png +0 -0
- data/public/img/flags/hu.png +0 -0
- data/public/img/flags/id.png +0 -0
- data/public/img/flags/ie.png +0 -0
- data/public/img/flags/il.png +0 -0
- data/public/img/flags/in.png +0 -0
- data/public/img/flags/io.png +0 -0
- data/public/img/flags/iq.png +0 -0
- data/public/img/flags/ir.png +0 -0
- data/public/img/flags/is.png +0 -0
- data/public/img/flags/it.png +0 -0
- data/public/img/flags/jm.png +0 -0
- data/public/img/flags/jo.png +0 -0
- data/public/img/flags/jp.png +0 -0
- data/public/img/flags/ke.png +0 -0
- data/public/img/flags/kg.png +0 -0
- data/public/img/flags/kh.png +0 -0
- data/public/img/flags/ki.png +0 -0
- data/public/img/flags/km.png +0 -0
- data/public/img/flags/kn.png +0 -0
- data/public/img/flags/kp.png +0 -0
- data/public/img/flags/kr.png +0 -0
- data/public/img/flags/kw.png +0 -0
- data/public/img/flags/ky.png +0 -0
- data/public/img/flags/kz.png +0 -0
- data/public/img/flags/la.png +0 -0
- data/public/img/flags/lb.png +0 -0
- data/public/img/flags/lc.png +0 -0
- data/public/img/flags/li.png +0 -0
- data/public/img/flags/lk.png +0 -0
- data/public/img/flags/lr.png +0 -0
- data/public/img/flags/ls.png +0 -0
- data/public/img/flags/lt.png +0 -0
- data/public/img/flags/lu.png +0 -0
- data/public/img/flags/lv.png +0 -0
- data/public/img/flags/ly.png +0 -0
- data/public/img/flags/ma.png +0 -0
- data/public/img/flags/mc.png +0 -0
- data/public/img/flags/md.png +0 -0
- data/public/img/flags/me.png +0 -0
- data/public/img/flags/mg.png +0 -0
- data/public/img/flags/mh.png +0 -0
- data/public/img/flags/mk.png +0 -0
- data/public/img/flags/ml.png +0 -0
- data/public/img/flags/mm.png +0 -0
- data/public/img/flags/mn.png +0 -0
- data/public/img/flags/mo.png +0 -0
- data/public/img/flags/mp.png +0 -0
- data/public/img/flags/mq.png +0 -0
- data/public/img/flags/mr.png +0 -0
- data/public/img/flags/ms.png +0 -0
- data/public/img/flags/mt.png +0 -0
- data/public/img/flags/mu.png +0 -0
- data/public/img/flags/mv.png +0 -0
- data/public/img/flags/mw.png +0 -0
- data/public/img/flags/mx.png +0 -0
- data/public/img/flags/my.png +0 -0
- data/public/img/flags/mz.png +0 -0
- data/public/img/flags/na.png +0 -0
- data/public/img/flags/nc.png +0 -0
- data/public/img/flags/ne.png +0 -0
- data/public/img/flags/nf.png +0 -0
- data/public/img/flags/ng.png +0 -0
- data/public/img/flags/ni.png +0 -0
- data/public/img/flags/nl.png +0 -0
- data/public/img/flags/no.png +0 -0
- data/public/img/flags/np.png +0 -0
- data/public/img/flags/nr.png +0 -0
- data/public/img/flags/nu.png +0 -0
- data/public/img/flags/nz.png +0 -0
- data/public/img/flags/om.png +0 -0
- data/public/img/flags/pa.png +0 -0
- data/public/img/flags/pe.png +0 -0
- data/public/img/flags/pf.png +0 -0
- data/public/img/flags/pg.png +0 -0
- data/public/img/flags/ph.png +0 -0
- data/public/img/flags/pk.png +0 -0
- data/public/img/flags/pl.png +0 -0
- data/public/img/flags/pm.png +0 -0
- data/public/img/flags/pn.png +0 -0
- data/public/img/flags/pr.png +0 -0
- data/public/img/flags/ps.png +0 -0
- data/public/img/flags/pt.png +0 -0
- data/public/img/flags/pw.png +0 -0
- data/public/img/flags/py.png +0 -0
- data/public/img/flags/qa.png +0 -0
- data/public/img/flags/re.png +0 -0
- data/public/img/flags/ro.png +0 -0
- data/public/img/flags/rs.png +0 -0
- data/public/img/flags/ru.png +0 -0
- data/public/img/flags/rw.png +0 -0
- data/public/img/flags/sa.png +0 -0
- data/public/img/flags/sb.png +0 -0
- data/public/img/flags/sc.png +0 -0
- data/public/img/flags/scotland.png +0 -0
- data/public/img/flags/sd.png +0 -0
- data/public/img/flags/se.png +0 -0
- data/public/img/flags/sg.png +0 -0
- data/public/img/flags/sh.png +0 -0
- data/public/img/flags/si.png +0 -0
- data/public/img/flags/sj.png +0 -0
- data/public/img/flags/sk.png +0 -0
- data/public/img/flags/sl.png +0 -0
- data/public/img/flags/sm.png +0 -0
- data/public/img/flags/sn.png +0 -0
- data/public/img/flags/so.png +0 -0
- data/public/img/flags/sr.png +0 -0
- data/public/img/flags/st.png +0 -0
- data/public/img/flags/sv.png +0 -0
- data/public/img/flags/sy.png +0 -0
- data/public/img/flags/sz.png +0 -0
- data/public/img/flags/tc.png +0 -0
- data/public/img/flags/td.png +0 -0
- data/public/img/flags/tf.png +0 -0
- data/public/img/flags/tg.png +0 -0
- data/public/img/flags/th.png +0 -0
- data/public/img/flags/tj.png +0 -0
- data/public/img/flags/tk.png +0 -0
- data/public/img/flags/tl.png +0 -0
- data/public/img/flags/tm.png +0 -0
- data/public/img/flags/tn.png +0 -0
- data/public/img/flags/to.png +0 -0
- data/public/img/flags/tr.png +0 -0
- data/public/img/flags/tt.png +0 -0
- data/public/img/flags/tv.png +0 -0
- data/public/img/flags/tw.png +0 -0
- data/public/img/flags/tz.png +0 -0
- data/public/img/flags/ua.png +0 -0
- data/public/img/flags/ug.png +0 -0
- data/public/img/flags/uk.png +0 -0
- data/public/img/flags/um.png +0 -0
- data/public/img/flags/us.png +0 -0
- data/public/img/flags/uy.png +0 -0
- data/public/img/flags/uz.png +0 -0
- data/public/img/flags/va.png +0 -0
- data/public/img/flags/vc.png +0 -0
- data/public/img/flags/ve.png +0 -0
- data/public/img/flags/vg.png +0 -0
- data/public/img/flags/vi.png +0 -0
- data/public/img/flags/vn.png +0 -0
- data/public/img/flags/vu.png +0 -0
- data/public/img/flags/wales.png +0 -0
- data/public/img/flags/wf.png +0 -0
- data/public/img/flags/ws.png +0 -0
- data/public/img/flags/ye.png +0 -0
- data/public/img/flags/yt.png +0 -0
- data/public/img/flags/za.png +0 -0
- data/public/img/flags/zm.png +0 -0
- data/public/img/flags/zw.png +0 -0
- data/public/img/glyphicons-halflings-white.png +0 -0
- data/public/img/glyphicons-halflings.png +0 -0
- data/public/js/bootstrap.js +1825 -0
- data/public/js/bootstrap.min.js +6 -0
- data/public/js/jquery-1.7.2.min.js +4 -0
- data/public/js/logs.js +194 -0
- data/spec/mongo_logger_spec.rb +33 -0
- data/spec/moped_logger_spec.rb +39 -0
- data/spec/query_spec.rb +80 -0
- data/spec/railtie_spec.rb +21 -0
- data/spec/shared_examples.rb +111 -0
- data/spec/spec_helper.rb +17 -0
- data/spec/testapp/config/logger.yml +6 -0
- data/spec/testapp/log/.gitkeep +0 -0
- data/views/index.erb +0 -0
- data/views/layout.erb +61 -0
- data/views/log_page.erb +22 -0
- data/views/logs.erb +76 -0
- metadata +402 -0
data/spec/query_spec.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'mongo_request_logger/search_terms'
|
3
|
+
|
4
|
+
include MongoRequestLogger
|
5
|
+
|
6
|
+
describe SearchTerms do
|
7
|
+
it "should search for paths by default" do
|
8
|
+
SearchTerms.new("/test/path").path.should == "/test/path"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should search for paths by default" do
|
12
|
+
SearchTerms.new("/test/path/").path.should == "/test/path/"
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should default to a nil path" do
|
16
|
+
SearchTerms.new("").path.should == nil
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should parse simple single parameters" do
|
20
|
+
SearchTerms.new("tag:rack").parts.should == {'tag' => "rack"}
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should parse complex single parameters" do
|
24
|
+
SearchTerms.new("tag:rack,mobile:stf").parts.should == {'tag' => "rack,mobile:stf"}
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should parse single parameter with path" do
|
28
|
+
terms = SearchTerms.new("/test/path tag:rack,mobile:stf")
|
29
|
+
terms.parts.should == {'tag' => "rack,mobile:stf"}
|
30
|
+
terms.path.should == '/test/path'
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should parse multiple parameters" do
|
34
|
+
SearchTerms.new("tag:rack user:315").parts.should == {'tag' => "rack", 'user' => '315'}
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should use additional text as search text" do
|
38
|
+
terms = SearchTerms.new("/test/path This is a test query")
|
39
|
+
terms.path.should == '/test/path'
|
40
|
+
terms.search.should == 'This is a test query'
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should parse parameters before search text" do
|
44
|
+
terms = SearchTerms.new("tag:rack This is a test query")
|
45
|
+
terms.path.should == nil
|
46
|
+
terms.parts.should == {'tag' => "rack"}
|
47
|
+
terms.search.should == 'This is a test query'
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should parse parameters after search text" do
|
51
|
+
terms = SearchTerms.new("/test/path This is a test query tag:rack")
|
52
|
+
terms.path.should == '/test/path'
|
53
|
+
terms.parts.should == {'tag' => "rack"}
|
54
|
+
terms.search.should == 'This is a test query'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should ignore characters inside quotes" do
|
58
|
+
terms = SearchTerms.new("/test/path \"This is a test:query\"")
|
59
|
+
terms.path.should == '/test/path'
|
60
|
+
terms.parts.should == {}
|
61
|
+
terms.search.should == 'This is a test:query'
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse regular expressions" do
|
65
|
+
terms = SearchTerms.new("/test/path /This\\sis.a:test/")
|
66
|
+
terms.path.should == '/test/path'
|
67
|
+
terms.parts.should == {}
|
68
|
+
terms.search_regex.should == "This\\sis.a:test"
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should parse regular expressions with parameters" do
|
72
|
+
terms = SearchTerms.new("/test/path /This\\sis.a:test/ tag:rack")
|
73
|
+
terms.path.should == '/test/path'
|
74
|
+
terms.parts.should == {'tag' => 'rack'}
|
75
|
+
terms.search_regex.should == "This\\sis.a:test"
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'spec_helper'
|
3
|
+
require 'mongo_request_logger/railtie'
|
4
|
+
|
5
|
+
class TestApp < Rails::Application
|
6
|
+
config.root = File.join(__FILE__, '../testapp')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe 'railtie' do
|
10
|
+
it "should load the Railtie" do
|
11
|
+
# For now, we mostly test that no errors are raised
|
12
|
+
MongoRequestLogger::Railtie.should be
|
13
|
+
MongoRequestLogger::Railtie.setup TestApp
|
14
|
+
|
15
|
+
File.exist?(Rails.root.join('log/test.log')).should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
after do
|
19
|
+
FileUtils.rm_f(Rails.root.join('log/test.log'))
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
shared_examples "log" do
|
2
|
+
|
3
|
+
|
4
|
+
it "should log without a request" do
|
5
|
+
logger = MongoRequestLogger::Logger.new @adapter, @file
|
6
|
+
logger.info "Test message"
|
7
|
+
logger.error "Test error"
|
8
|
+
logger.close
|
9
|
+
lines = File.open(@file).readlines
|
10
|
+
lines.last.should match /Test error/
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should log requests" do
|
14
|
+
logger = MongoRequestLogger::Logger.new @adapter, @file
|
15
|
+
options = {test_option: "Test value", args: {"one" => "Value"}}
|
16
|
+
logger.log_request(options) do
|
17
|
+
logger.add_metadata value: "Test"
|
18
|
+
logger.tag "test1"
|
19
|
+
logger.tag "test2", "test3"
|
20
|
+
|
21
|
+
logger.info "Test message"
|
22
|
+
logger.error "Test error"
|
23
|
+
end
|
24
|
+
log = @adapter.collection.find.first
|
25
|
+
log.should be
|
26
|
+
|
27
|
+
log['test_option'].should == "Test value"
|
28
|
+
log['args'].should == {"one" => "Value"}
|
29
|
+
log['value'].should == "Test"
|
30
|
+
log['tags'].should == %w(test1 test2 test3)
|
31
|
+
log['runtime'].should be
|
32
|
+
log['timestamp'].should be
|
33
|
+
log['pid'].should be
|
34
|
+
messages = log['messages']
|
35
|
+
messages[0].should match /INFO.*Test message/
|
36
|
+
messages[1].should match /ERROR.*Test error/
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should log exceptions" do
|
40
|
+
class MyError < StandardError; end
|
41
|
+
logger = MongoRequestLogger::Logger.new @adapter, @file
|
42
|
+
options = {test_option: "Test value", args: {"one" => "Value"}}
|
43
|
+
logger.log_request(options) do
|
44
|
+
logger.info "Test message"
|
45
|
+
begin
|
46
|
+
raise MyError, "Test error"
|
47
|
+
rescue => e
|
48
|
+
logger.exception e
|
49
|
+
end
|
50
|
+
end
|
51
|
+
log = @adapter.collection.find.first
|
52
|
+
log.should be
|
53
|
+
|
54
|
+
messages = log['messages']
|
55
|
+
messages[0].should match /INFO.*Test message/
|
56
|
+
messages[1].should match /ERROR.*Test error.*\n.*shared_examples\.rb/
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should log raised errors" do
|
60
|
+
class MyError < StandardError; end
|
61
|
+
|
62
|
+
logger = MongoRequestLogger::Logger.new @adapter, @file
|
63
|
+
options = {test_option: "Test value", args: {"one" => "Value"}}
|
64
|
+
block = ->{
|
65
|
+
logger.log_request do
|
66
|
+
logger.info "Test message"
|
67
|
+
raise MyError, "This is a test"
|
68
|
+
end
|
69
|
+
}
|
70
|
+
|
71
|
+
block.should raise_error(MyError)
|
72
|
+
|
73
|
+
log = @adapter.collection.find.first
|
74
|
+
log.should be
|
75
|
+
|
76
|
+
log['runtime'].should be
|
77
|
+
log['timestamp'].should be
|
78
|
+
log['exception'].should == {"class"=>"MyError", "message"=>"This is a test"}
|
79
|
+
messages = log['messages']
|
80
|
+
messages[0].should match /INFO.*Test message/
|
81
|
+
messages[1].should match /ERROR.*MyError.*This is a test.*\n.*shared_examples\.rb/
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should log SystemStackErrors" do
|
85
|
+
def infinite_recursion n=0
|
86
|
+
infinite_recursion(n+1)
|
87
|
+
end
|
88
|
+
|
89
|
+
logger = MongoRequestLogger::Logger.new @adapter, @file
|
90
|
+
block = ->{
|
91
|
+
logger.log_request do
|
92
|
+
begin
|
93
|
+
infinite_recursion
|
94
|
+
rescue => e
|
95
|
+
logger.exception e
|
96
|
+
raise e
|
97
|
+
end
|
98
|
+
end
|
99
|
+
}
|
100
|
+
|
101
|
+
block.should raise_error(SystemStackError)
|
102
|
+
|
103
|
+
log = @adapter.collection.find.first
|
104
|
+
log.should be
|
105
|
+
|
106
|
+
log['exception'].should == {"class"=>"SystemStackError", "message"=>"stack level too deep"}
|
107
|
+
messages = log['messages']
|
108
|
+
messages[0].should match /ERROR.*SystemStackError.*stack level too deep/
|
109
|
+
puts messages
|
110
|
+
end
|
111
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
if ENV['COVERAGE']
|
3
|
+
require 'simplecov'
|
4
|
+
SimpleCov.start do
|
5
|
+
add_filter '/spec/'
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'rails'
|
10
|
+
Rails.backtrace_cleaner.remove_silencers!
|
11
|
+
ENV["RAILS_ENV"] = 'test'
|
12
|
+
|
13
|
+
# Require all files, so they show up in coverage
|
14
|
+
Dir['lib/**/*.rb'].each do |file|
|
15
|
+
path = /lib\/(.*)\.rb/.match(file)[1]
|
16
|
+
require path
|
17
|
+
end
|
File without changes
|
data/views/index.erb
ADDED
File without changes
|
data/views/layout.erb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<title><%= @title %></title>
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
|
+
<meta name="description" content="">
|
8
|
+
<meta name="author" content="">
|
9
|
+
|
10
|
+
<!-- Le styles -->
|
11
|
+
<link href="<%= url('/css/bootstrap.css') %>" rel="stylesheet">
|
12
|
+
<style>
|
13
|
+
body {
|
14
|
+
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
15
|
+
}
|
16
|
+
</style>
|
17
|
+
<link href="<%= url('/css/bootstrap-responsive.css') %>" rel="stylesheet">
|
18
|
+
|
19
|
+
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
20
|
+
<!--[if lt IE 9]>
|
21
|
+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
22
|
+
|
23
|
+
<![endif]-->
|
24
|
+
</head>
|
25
|
+
|
26
|
+
<body>
|
27
|
+
|
28
|
+
<div class="navbar navbar-fixed-top">
|
29
|
+
<div class="navbar-inner">
|
30
|
+
<div class="container">
|
31
|
+
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
32
|
+
<span class="icon-bar"></span>
|
33
|
+
<span class="icon-bar"></span>
|
34
|
+
<span class="icon-bar"></span>
|
35
|
+
</a>
|
36
|
+
<a class="brand" href="<%= url('/') %>">Log Viewer</a>
|
37
|
+
<!--<div class="nav-collapse">-->
|
38
|
+
<!--<ul class="nav">-->
|
39
|
+
<!--<li class="active"><a href="/">Home</a></li>-->
|
40
|
+
<!--<li><a href="#about">About</a></li>-->
|
41
|
+
<!--<li><a href="#contact">Contact</a></li>-->
|
42
|
+
<!--</ul>-->
|
43
|
+
<!--</div>-->
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<div class="container">
|
49
|
+
|
50
|
+
<%= yield %>
|
51
|
+
|
52
|
+
</div> <!-- /container -->
|
53
|
+
|
54
|
+
<!-- Le javascript
|
55
|
+
================================================== -->
|
56
|
+
<!-- Placed at the end of the document so the pages load faster -->
|
57
|
+
<script src="<%= url('/js/jquery-1.7.2.min.js') %>"></script>
|
58
|
+
<script src="<%= url('/js/bootstrap.js') %>"></script>
|
59
|
+
|
60
|
+
</body>
|
61
|
+
</html>
|
data/views/log_page.erb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
<h4>Request</h4>
|
3
|
+
<table class="table table-striped table-bordered table-condensed">
|
4
|
+
<tr><td>Path</td><td><%=h @log.path %></td></tr>
|
5
|
+
<tr><td>Time</td><td><%=h @log.time %></td></tr>
|
6
|
+
<tr><td>Response</td><td><%=h @log.response %></td></tr>
|
7
|
+
<% if @log.exception %><tr><td>Error</td><td><%=h @log.exception %></td></tr><% end %>
|
8
|
+
<tr><td>Tags</td><td><%=h @log.tags.join(' ') %></td></tr>
|
9
|
+
<% if @log.args %><tr><td>Args</td><td><%=h @log.args %></td></tr><% end %>
|
10
|
+
<% if @log.params %><tr><td>Params</td><td><%=h @log.params %></td></tr><% end %>
|
11
|
+
<% @log.extra(%w(_id path timestamp response exception messages tags args)).each do |key, value| %>
|
12
|
+
<tr><td><%= key %></td><td><%=h value.to_s.truncate(150) %></td></tr>
|
13
|
+
<% end %>
|
14
|
+
</table>
|
15
|
+
|
16
|
+
<h4>Messages</h4>
|
17
|
+
<pre>
|
18
|
+
<% @log.messages.each do |message| %>
|
19
|
+
<%=h message %>
|
20
|
+
|
21
|
+
<% end %>
|
22
|
+
</pre>
|
data/views/logs.erb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
<div class="well form-search">
|
2
|
+
<input type="text" class="input-xxlarge search-query" id="search_text" name="q" />
|
3
|
+
<button class="btn search_button" id="search_button">Search</button>
|
4
|
+
<button class="btn" id="refresh_button"><i class="icon-refresh"></i></button>
|
5
|
+
<button class="btn" id="help_button"><i class="icon-question-sign"></i></button>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div id="errors">
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div id="help" style="display: none;">
|
12
|
+
<h4>Examples</h4>
|
13
|
+
<table class="table table-bordered">
|
14
|
+
<tbody>
|
15
|
+
<tr><td>Search by path prefix</td><td><code>/the/path</code></td></tr>
|
16
|
+
<tr><td>Search by exact path</td><td><code>/the/path$</code></td></tr>
|
17
|
+
<tr><td>Search by tag</td><td><code>tag:rack</code></td></tr>
|
18
|
+
<tr><td>Pages with errors</td><td><code>error:1</code></td></tr>
|
19
|
+
<tr><td>HTTP 200</td><td><code>response:200</code></td></tr>
|
20
|
+
<tr><td>Search by object ID</td><td><code>id:12345</code></td></tr>
|
21
|
+
<tr><td>Search by user ID</td><td><code>user:12345</code></td></tr>
|
22
|
+
<tr><td>Filter by keyword</td><td><code>/the/path keyword</code></td></tr>
|
23
|
+
<tr><td>Filter by multiple keywords</td><td><code>/the/path "multiple keywords"</code></td></tr>
|
24
|
+
<tr><td>Filter by regular expression</td><td><code>/the/path /the regex/</code></td></tr>
|
25
|
+
<tr><td>Filter by regular expression</td><td><code>/the/path /the regex/</code></td></tr>
|
26
|
+
<tr><td>Combination of the above</td><td><code>/the/path error:1 tag:rack "some keywords"</code></td></tr>
|
27
|
+
</tbody>
|
28
|
+
</table>
|
29
|
+
</div>
|
30
|
+
<br />
|
31
|
+
|
32
|
+
<table class="table table-striped" id="search_results">
|
33
|
+
<thead>
|
34
|
+
<tr>
|
35
|
+
<th>Time</th>
|
36
|
+
<th style="max-width: 150px;">Path</th>
|
37
|
+
<th style="max-width: 200px;">Referer</th>
|
38
|
+
<th>User</th>
|
39
|
+
<th>IP</th>
|
40
|
+
<th>Location</th>
|
41
|
+
<th>Response</th>
|
42
|
+
<th>User Agent</th>
|
43
|
+
<th>Runtime</th>
|
44
|
+
<th>Details</th>
|
45
|
+
</tr>
|
46
|
+
</thead>
|
47
|
+
<tbody>
|
48
|
+
</tbody>
|
49
|
+
<tfoot>
|
50
|
+
<tr>
|
51
|
+
<td colspan="7">
|
52
|
+
<button class="btn" id="more_button">Show more results</button>
|
53
|
+
</td>
|
54
|
+
</tr>
|
55
|
+
</tfoot>
|
56
|
+
</table>
|
57
|
+
|
58
|
+
<!--%= will_paginate @pagination %-->
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
<pre id="search_query"></pre>
|
63
|
+
|
64
|
+
<script type="text/javascript">
|
65
|
+
var log_base_url = "<%= url("/") %>";
|
66
|
+
</script>
|
67
|
+
<script src="<%= url('/js/logs.js') %>"></script>
|
68
|
+
|
69
|
+
<style type="text/css">
|
70
|
+
/*.table tbody tr.log-row td:hover {*/
|
71
|
+
/*cursor: pointer;*/
|
72
|
+
/*}*/
|
73
|
+
|
74
|
+
/*.table-row { display: table-row; }*/
|
75
|
+
/*.table-cell { display: table-cell; }*/
|
76
|
+
</style>
|