rackamole 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +2 -3
- data/lib/rackamole.rb +1 -1
- data/lib/rackamole/mole.rb +22 -1
- data/lib/rackamole/store/mongo.rb +3 -3
- metadata +2 -2
data/History.txt
CHANGED
data/lib/rackamole.rb
CHANGED
data/lib/rackamole/mole.rb
CHANGED
@@ -73,7 +73,9 @@ module Rack
|
|
73
73
|
def mole_info( env, elapsed, status, headers, body )
|
74
74
|
request = Rack::Request.new( env )
|
75
75
|
info = OrderedHash.new
|
76
|
-
|
76
|
+
|
77
|
+
# dump( env )
|
78
|
+
|
77
79
|
return info unless mole_request?( request )
|
78
80
|
|
79
81
|
session = env['rack.session']
|
@@ -83,6 +85,8 @@ module Rack
|
|
83
85
|
user_id = nil
|
84
86
|
user_name = nil
|
85
87
|
|
88
|
+
# BOZO !! This could be slow if have to query db to get user name...
|
89
|
+
# Preferred store username in session and give at key
|
86
90
|
if session and @user_key
|
87
91
|
if @user_key.instance_of? Symbol
|
88
92
|
user_name = session[@user_key]
|
@@ -100,6 +104,8 @@ module Rack
|
|
100
104
|
info[:user_name] = user_name || "Unknown"
|
101
105
|
info[:ip] = ip
|
102
106
|
info[:browser] = browser
|
107
|
+
info[:host] = env['SERVER_NAME']
|
108
|
+
info[:software] = env['SERVER_SOFTWARE']
|
103
109
|
info[:request_time] = elapsed if elapsed
|
104
110
|
info[:perf_issue] = (elapsed and elapsed > @perf_threshold)
|
105
111
|
info[:url] = request.url
|
@@ -152,5 +158,20 @@ module Rack
|
|
152
158
|
return nil unless defined?( RAILS_ENV )
|
153
159
|
::ActionController::Routing::Routes.recognize_path( request.path, {:method => request.request_method.downcase.to_sym } )
|
154
160
|
end
|
161
|
+
|
162
|
+
# Dump env to stdout
|
163
|
+
def dump( env, level=0 )
|
164
|
+
env.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k|
|
165
|
+
value = env[k]
|
166
|
+
if value.respond_to?(:each_pair)
|
167
|
+
puts "%s %-#{40-level}s" % [' '*level,k]
|
168
|
+
dump( env[k], level+1 )
|
169
|
+
elsif value.instance_of?(::ActionController::Request) or value.instance_of?(::ActionController::Response)
|
170
|
+
puts "%s %-#{40-level}s %s" % [ ' '*level, k, value.class ]
|
171
|
+
else
|
172
|
+
puts "%s %-#{40-level}s %s" % [ ' '*level, k, value.inspect ]
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
155
176
|
end
|
156
177
|
end
|
@@ -12,9 +12,9 @@ module Rackamole
|
|
12
12
|
|
13
13
|
attr_reader :connection
|
14
14
|
|
15
|
-
def initialize( options )
|
15
|
+
def initialize( options={} )
|
16
16
|
opts = default_options.merge( options )
|
17
|
-
@connection = Connection.new( opts[:
|
17
|
+
@connection = Connection.new( opts[:host], opts[:port] ).db( opts[:database] )
|
18
18
|
end
|
19
19
|
|
20
20
|
# clear out db content
|
@@ -52,7 +52,7 @@ module Rackamole
|
|
52
52
|
def default_options
|
53
53
|
{
|
54
54
|
:host => 'localhost',
|
55
|
-
:port =>
|
55
|
+
:port => 27017,
|
56
56
|
:database => 'mole_mdb'
|
57
57
|
}
|
58
58
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackamole
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fernand Galiana
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-16 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|