Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joshua Clayton
committed
Apr 18, 2009
1 parent
2567807
commit 5d90eaf
Showing
13 changed files
with
204 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
class WatchedException < ActiveRecord::Base | ||
include Watchtower::WatchedExceptionBase | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>Exception</th> | ||
<th>Message</th> | ||
<th>Controller Action</th> | ||
<th>Created</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<% watched_exceptions.each do |exception| %> | ||
<tr> | ||
<td><%= link_to exception.exception_class, watchtower_path(exception) %></td> | ||
<td><%= h exception.message %></td> | ||
<td><%= exception.controller_action %></td> | ||
<td><%= distance_of_time_in_words_to_now exception.created_at %> ago</td> | ||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
<%= will_paginate watched_exceptions %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,40 @@ | ||
welcome | ||
<div class="content-main"> | ||
<%= render :partial => "recordset", :locals => {:watched_exceptions => @watched_exceptions} %> | ||
</div> | ||
<div class="content-extra"> | ||
<ul class="filter-exception_class"> | ||
<% WatchedException.exception_classes.each do |exception_class| %> | ||
<li><%= exception_class %></li> | ||
<% end %> | ||
</ul> | ||
<ul class="filter-controller_action"> | ||
<% WatchedException.controller_actions.each do |controller_action| %> | ||
<li><%= controller_action %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% content_for :footer do %> | ||
<script type="text/javascript"> | ||
(function($) { | ||
var watchtower = $.watchtower(); | ||
|
||
$("ul[class^=filter-] li").each(function(idx, li) { | ||
var $li = $(li), | ||
filter = $li.parent().attr("class").replace("filter-", ""), | ||
name = $li.text(); | ||
|
||
$li.click(function() { | ||
watchtower.filters(filter).clear(); | ||
|
||
if($li.hasClass("active-filter")) { | ||
$li.removeClass("active-filter"); | ||
} else { | ||
$li.siblings().removeClass("active-filter"); | ||
$li.addClass("active-filter"); | ||
watchtower.filters(filter).add(name); | ||
} | ||
}); | ||
}); | ||
})(jQuery); | ||
</script> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h2><%= @watched_exception.exception_class %> in <%= @watched_exception.controller_action %></h2> | ||
<h3><%= h @watched_exception.message %></h3> | ||
<dl> | ||
<dt>Created</dt> | ||
<dd><%= distance_of_time_in_words_to_now @watched_exception.created_at %> ago (<%= @watched_exception.created_at.to_s(:long) %>)</dd> | ||
<dt>Parameters</dt> | ||
<dd><code><%= @watched_exception.parameters %></code></dd> | ||
<dt>Backtrace</dt> | ||
<dd><code><pre><%= h @watched_exception.backtrace.strip %></pre></code></dd> | ||
<dt>Format</dt> | ||
<dd><code><%= h @watched_exception.format %></code></dd> | ||
<dt>Application Path</dt> | ||
<dd><code><%= h @watched_exception.application_path %></code></dd> | ||
<dt>Full Request</dt> | ||
<dd><code><%= h @watched_exception.request %></code></dd> | ||
</dl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
# Include hook code here | ||
require "will_paginate" | ||
require "watchtower" | ||
WatchedException.send :include, Watchtower::WatchedExceptionBase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
# Watchtower | ||
require "watchtower/controller_base" | ||
require "watchtower/watched_exception_base" | ||
require "watchtower/controller_base" | ||
require "watchtower/application_controller_base" | ||
require "watchtower/watched_exceptions_presenter" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
require "ipaddr" | ||
|
||
module Watchtower | ||
module ApplicationControllerBase | ||
|
||
def self.included(base) | ||
base.class_eval do | ||
def rescue_action_in_public_with_watchtower(*args) | ||
WatchedException.create_from_exception(self, args.first) | ||
rescue_action_in_public_without_watchtower(*args) | ||
end | ||
|
||
alias_method_chain :rescue_action_in_public, :watchtower | ||
end | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class WatchedExceptionsPresenter | ||
include Enumerable | ||
|
||
def initialize(params) | ||
scope = WatchedException | ||
scope = scope.search("%#{params[:query]}%") if params[:query] | ||
scope = scope.scoped_by_action_name(params[:action_name]) if params[:action_name] | ||
scope = scope.scoped_by_controller_name(params[:controller_name]) if params[:controller_name] | ||
scope = scope.scoped_by_controller_action(params[:controller_action]) if params[:controller_action] | ||
scope = scope.scoped_by_exception_class(params[:exception_class]) if params[:exception_class] | ||
@watched_exceptions = scope.paginate(:page => params[:page], :per_page => 20) | ||
end | ||
|
||
def each(&block) | ||
@watched_exceptions.each(&block) | ||
end | ||
|
||
def method_missing(call, *args) | ||
@watched_exceptions.send call, *args | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(function($) { | ||
var $doc = $(document); | ||
|
||
$.watchtower = function() { | ||
var self = {}, | ||
filterCache = {}; | ||
|
||
return { | ||
filters: function(name) { | ||
return { | ||
set: function(filter) { | ||
if(filterCache[name]) { $doc.trigger("watchtower-filter-remove", {filter: filter, name: name}); } | ||
filterCache[name] = filter; | ||
$doc.trigger("watchtower-filter-add", {filter: filter, name: name}); | ||
}, | ||
clear: function() { | ||
var oldFilter = filterCache[name]; | ||
filterCache[name] = null; | ||
$doc.trigger("watchtower-filter-remove", {filter: oldFilter, name: name}); | ||
} | ||
}; | ||
} | ||
}; | ||
}; | ||
|
||
$.watchtower.bindings = function() { | ||
$doc.bind("watchtower-filter-add", function(event, info) { | ||
$doc.trigger("watchtower-filter-change", info); | ||
}); | ||
|
||
$doc.bind("watchtower-filter-remove", function(event, info) { | ||
$doc.trigger("watchtower-filter-change", info); | ||
}); | ||
|
||
$doc.bind("watchtower-filter-change", function(event, info) { | ||
|
||
}); | ||
}; | ||
})(jQuery); |