Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

a tad nicer looking and splits sessions

  • Loading branch information...
commit a24e5f88f10061b90d8d13501617972f4829252c 1 parent 69b16dc
Scott Chacon authored
4 browser/browser.rb
View
@@ -58,10 +58,10 @@ def get_line(data)
@sessions = []
sessions = @snifter.current
sessions.each do |sess|
- req, res = @snifter.session(sess)
+ req, res, time = @snifter.session(sess)
req = get_line(req)
res = get_line(res)
- @sessions << [sess, req, res]
+ @sessions << [sess, req, res, time]
end
erb :index
end
1  browser/public/style.css
View
@@ -5,6 +5,7 @@ h1 {
#results { padding: 0 20px; }
.details { font-size: 80%; }
+a.session { color: #363; }
table.headers {
font-family: monospace;
7 browser/views/index.erb
View
@@ -2,7 +2,12 @@
<tr><td valign="top">
<h1>Sessions</h1>
<table>
- <% @sessions.each do |sess, req, res| %>
+ <% last_time = 0 %>
+ <% @sessions.each do |sess, req, res, time| %>
+ <% if (time - last_time) > 2 %>
+ <tr><td colspan="2"><hr/></td></tr>
+ <% end %>
+ <% last_time = time %>
<tr>
<td nowrap><a class="session" href="#" rel="/sess/<%= sess %>"><%= req %></a></td>
<td nowrap><%= res %></td>
6 snifter.rb
View
@@ -14,10 +14,11 @@ def conn_id(conn)
def update_list(id)
@redis.rpush LIST_ID, id
- @redis.ltrim LIST_ID, -10, -1
+ @redis.ltrim LIST_ID, -50, -1
end
def log_connect(conn)
+ add_data(conn, 'time', Time.now.to_i)
update_list(conn_id(conn))
end
@@ -48,7 +49,8 @@ def current
def session(session)
req = @redis.get session + 'request'
res = @redis.get session + 'response'
- [req, res]
+ time = @redis.get session + 'time'
+ [req, res, time.to_i]
end
def show_stats
Please sign in to comment.
Something went wrong with that request. Please try again.