tartarus 1.0.0 → 1.0.1
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/README.rdoc +2 -3
- data/VERSION +1 -1
- data/generators/tartarus/tartarus_generator.rb +0 -1
- data/generators/tartarus/templates/config/exceptions.yml +3 -3
- data/generators/tartarus/templates/public/javascripts/tartarus.jquery.js +7 -5
- data/generators/tartarus/templates/public/stylesheets/tartarus.css +2 -2
- data/lib/tartarus/logger.rb +5 -8
- data/lib/tartarus/rescue.rb +3 -1
- data/lib/tartarus.rb +4 -1
- data/spec/tartarus/logger_spec.rb +3 -2
- data/spec/tartarus/rescue_spec.rb +13 -0
- data/spec/tartarus_spec.rb +14 -1
- data/tartarus.gemspec +113 -0
- metadata +3 -2
data/README.rdoc
CHANGED
@@ -16,8 +16,8 @@ dependencies are used:
|
|
16
16
|
|
17
17
|
=== Installation
|
18
18
|
|
19
|
-
1. Install the gem:
|
20
|
-
[sudo] gem install tartarus
|
19
|
+
1. Install the gem from:
|
20
|
+
[sudo] gem install tartarus --source=http://gemcutter.org
|
21
21
|
2. Add the exceptional gem dependency to your enviroment.rb:
|
22
22
|
config.gem "tartarus"
|
23
23
|
3. Run the generator from the root of your Rails application:
|
@@ -27,7 +27,6 @@ dependencies are used:
|
|
27
27
|
5. Add the javascript and stylesheet includes in your layout:
|
28
28
|
<script type="text/javascript" src="/javascripts/tartarus.jquery.js"></script>
|
29
29
|
<link href="/stylesheets/tartarus.css" media="all" rel="stylesheet" type="text/css" />
|
30
|
-
6. View the generated 'config/exceptions.yml' file and make sure the default options are correct.
|
31
30
|
|
32
31
|
=== License
|
33
32
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
@@ -46,6 +46,5 @@ class TartarusGenerator < Rails::Generator::NamedBase
|
|
46
46
|
puts "\nIn order for exceptional to function properly, you'll need to complete the following steps to complete the installation process: \n\n"
|
47
47
|
puts " 1) Run 'rake db:migrate' to generate the logging table for your model.\n"
|
48
48
|
puts " 2) Add '/javascripts/tartarus.jquery.js', and 'stylesheets/tartarus.css' to your applications layout.\n"
|
49
|
-
puts " 3) View 'config/exceptions.yml' and make sure the default options are correct.\n\n"
|
50
49
|
end
|
51
50
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
development:
|
2
|
-
|
2
|
+
logging_enabled: true
|
3
3
|
logger_class: <%= class_name %>
|
4
4
|
test:
|
5
|
-
|
5
|
+
logging_enabled: false
|
6
6
|
logger_class: <%= class_name %>
|
7
7
|
production:
|
8
|
-
|
8
|
+
logging_enabled: true
|
9
9
|
logger_class: <%= class_name %>
|
@@ -1,6 +1,8 @@
|
|
1
|
-
|
2
|
-
$(
|
3
|
-
|
4
|
-
|
1
|
+
(function($) {
|
2
|
+
$(function() {
|
3
|
+
$('.togglable').each(function() {
|
4
|
+
var toggle_data = $(this).find('.toggle_data');
|
5
|
+
$(this).find('.toggle_link').click(function() { toggle_data.toggle(); })
|
6
|
+
});
|
5
7
|
});
|
6
|
-
});
|
8
|
+
})(jQuery);
|
@@ -22,5 +22,5 @@
|
|
22
22
|
#tartarus #exception { clear: both; }
|
23
23
|
#tartarus #exception_actions { float: right; }
|
24
24
|
|
25
|
-
.toggle_data { display: none }
|
26
|
-
#backtrace_information .toggle_data { display: block; }
|
25
|
+
#tartarus .toggle_data { display: none }
|
26
|
+
#tartarus #backtrace_information .toggle_data { display: block; }
|
data/lib/tartarus/logger.rb
CHANGED
@@ -20,23 +20,20 @@ module Tartarus::Logger
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def normalize_request_data(request)
|
23
|
+
enviroment = request.env.dup
|
24
|
+
|
23
25
|
request_details = {
|
24
|
-
:enviroment => {},
|
26
|
+
:enviroment => { :process => $$, :server => `hostname -s`.chomp },
|
27
|
+
:session => { :variables => enviroment['rack.session'].to_hash, :cookie => enviroment['rack.request.cookie_hash'] },
|
25
28
|
:http_details => {
|
26
29
|
:method => request.method.to_s.upcase,
|
27
30
|
:url => "#{request.protocol}#{request.env["HTTP_HOST"]}#{request.request_uri}",
|
28
31
|
:format => request.format.to_s,
|
29
32
|
:parameters => request.parameters
|
30
|
-
},
|
31
|
-
|
32
|
-
:session => {
|
33
|
-
:variables => request.env['rack.session'],
|
34
|
-
:options => request.env['rack.session.options'],
|
35
|
-
:cookie => request.env['rack.request.cookie_hash']
|
36
33
|
}
|
37
34
|
}
|
38
35
|
|
39
|
-
|
36
|
+
enviroment.each_pair do |key, value|
|
40
37
|
request_details[:enviroment][key.downcase] = value if key.match(/^[A-Z_]*$/)
|
41
38
|
end
|
42
39
|
|
data/lib/tartarus/rescue.rb
CHANGED
@@ -6,7 +6,9 @@ module Tartarus::Rescue
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def rescue_action_with_tartarus(exception)
|
9
|
-
|
9
|
+
is_exception = response_code_for_rescue(exception) == :internal_server_error
|
10
|
+
|
11
|
+
if is_exception and Tartarus.logging_enabled?
|
10
12
|
Tartarus.log(self, exception)
|
11
13
|
end
|
12
14
|
|
data/lib/tartarus.rb
CHANGED
@@ -10,12 +10,15 @@ class Tartarus
|
|
10
10
|
def logger_class
|
11
11
|
configuration['logger_class'].constantize
|
12
12
|
end
|
13
|
+
|
14
|
+
def logging_enabled?
|
15
|
+
configuration['logging_enabled'] == true
|
16
|
+
end
|
13
17
|
|
14
18
|
def log(controller, exception)
|
15
19
|
logger_class.log(controller, exception)
|
16
20
|
end
|
17
21
|
end
|
18
|
-
|
19
22
|
end
|
20
23
|
|
21
24
|
require 'tartarus/logger'
|
@@ -42,12 +42,13 @@ describe Tartarus::Logger do
|
|
42
42
|
|
43
43
|
it 'should have a enviroment hash that contains a hash of only the uppercase keys of the original controller request hash' do
|
44
44
|
@request_data[:enviroment].should_not be_blank
|
45
|
-
@request_data[:enviroment].should == { "http_host" => "test_host", "loooooooong_key_two" => "key_two_value", "key_one" => "key_one_value"}
|
45
|
+
@request_data[:enviroment].should == { "http_host" => "test_host", "loooooooong_key_two" => "key_two_value", "key_one" => "key_one_value", :server => `hostname -s`.chomp, :process => $$ }
|
46
46
|
end
|
47
47
|
|
48
48
|
it 'should have a session hash' do
|
49
49
|
@request_data[:session].should_not be_blank
|
50
|
-
@request_data[:session].should
|
50
|
+
@request_data[:session].should be_an_instance_of(Hash)
|
51
|
+
@request_data[:session].should == { :cookie => {}, :variables => { :id=>"123123" } }
|
51
52
|
end
|
52
53
|
|
53
54
|
it 'should have a http details hash' do
|
@@ -20,6 +20,7 @@ describe Tartarus::Rescue do
|
|
20
20
|
@exception = StandardError.new
|
21
21
|
@controller.stub!(:rescue_action_without_tartarus)
|
22
22
|
@controller.stub!(:response_code_for_rescue).and_return(:internal_server_error)
|
23
|
+
Tartarus.stub!(:logging_enabled?).and_return(true)
|
23
24
|
Tartarus.stub!(:log)
|
24
25
|
end
|
25
26
|
|
@@ -34,6 +35,18 @@ describe Tartarus::Rescue do
|
|
34
35
|
@controller.rescue_action_with_tartarus(@exception)
|
35
36
|
end
|
36
37
|
|
38
|
+
it 'should log the exception with tartarus if exception logging is enabled' do
|
39
|
+
Tartarus.should_receive(:logging_enabled?).and_return(true)
|
40
|
+
@controller.rescue_action_with_tartarus(@exception)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should not log the exception with tartarus if exception logging is disabled' do
|
44
|
+
Tartarus.should_receive(:logging_enabled?).and_return(false)
|
45
|
+
Tartarus.should_receive(:log).never
|
46
|
+
|
47
|
+
@controller.rescue_action_with_tartarus(@exception)
|
48
|
+
end
|
49
|
+
|
37
50
|
it 'should invoke rescue_action_without_tartarus' do
|
38
51
|
@controller.should_receive(:rescue_action_without_tartarus)
|
39
52
|
@controller.rescue_action_with_tartarus(@exception)
|
data/spec/tartarus_spec.rb
CHANGED
@@ -11,6 +11,19 @@ describe Tartarus do
|
|
11
11
|
Tartarus.logger_class.should == LoggedException
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "#logging_enabled?" do
|
16
|
+
it 'should return false if logging is not enabled in the configuration' do
|
17
|
+
Tartarus.should_receive(:configuration).and_return({ 'logging_enabled' => false })
|
18
|
+
Tartarus.logging_enabled?.should be_false
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should return true if logging is enabled in the configuration' do
|
22
|
+
Tartarus.should_receive(:configuration).and_return({ 'logging_enabled' => true })
|
23
|
+
Tartarus.logging_enabled?.should be_true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
14
27
|
|
15
28
|
describe "#log" do
|
16
29
|
before(:each) do
|
@@ -32,7 +45,7 @@ describe Tartarus do
|
|
32
45
|
|
33
46
|
describe "#configuration" do
|
34
47
|
before(:each) do
|
35
|
-
YAML.stub!(:load_file).and_return({'development' => { 'enabled' => true }, 'test' => { 'enabled' => false } })
|
48
|
+
YAML.stub!(:load_file).and_return({ 'development' => { 'enabled' => true }, 'test' => { 'enabled' => false } })
|
36
49
|
end
|
37
50
|
|
38
51
|
it 'should parse the YAML configuration file for exceptional' do
|
data/tartarus.gemspec
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{tartarus}
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Daniel Insley"]
|
12
|
+
s.date = %q{2009-11-24}
|
13
|
+
s.description = %q{Provides exception logging and a generator for creating a clean interface to manage exceptions.}
|
14
|
+
s.email = %q{dinsley@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"generators/tartarus/USAGE",
|
25
|
+
"generators/tartarus/tartarus_generator.rb",
|
26
|
+
"generators/tartarus/templates/app/controllers/exceptions_controller.rb",
|
27
|
+
"generators/tartarus/templates/app/models/logged_exception.rb",
|
28
|
+
"generators/tartarus/templates/app/views/exceptions/_exception.html.erb",
|
29
|
+
"generators/tartarus/templates/app/views/exceptions/details.html.erb",
|
30
|
+
"generators/tartarus/templates/app/views/exceptions/index.html.erb",
|
31
|
+
"generators/tartarus/templates/config/exceptions.yml",
|
32
|
+
"generators/tartarus/templates/db/migrate/add_logged_exceptions.rb",
|
33
|
+
"generators/tartarus/templates/public/javascripts/tartarus.jquery.js",
|
34
|
+
"generators/tartarus/templates/public/stylesheets/tartarus.css",
|
35
|
+
"generators/tartarus/templates/spec/controllers/exceptions_controller_spec.rb",
|
36
|
+
"generators/tartarus/templates/spec/models/logged_exception_spec.rb",
|
37
|
+
"lib/tartarus.rb",
|
38
|
+
"lib/tartarus/logger.rb",
|
39
|
+
"lib/tartarus/rescue.rb",
|
40
|
+
"rails/init.rb",
|
41
|
+
"spec/rails/app/controllers/application_controller.rb",
|
42
|
+
"spec/rails/app/models/logged_exception.rb",
|
43
|
+
"spec/rails/config/boot.rb",
|
44
|
+
"spec/rails/config/database.yml",
|
45
|
+
"spec/rails/config/environment.rb",
|
46
|
+
"spec/rails/config/environments/development.rb",
|
47
|
+
"spec/rails/config/environments/production.rb",
|
48
|
+
"spec/rails/config/environments/test.rb",
|
49
|
+
"spec/rails/config/exceptions.yml",
|
50
|
+
"spec/rails/config/initializers/backtrace_silencers.rb",
|
51
|
+
"spec/rails/config/initializers/inflections.rb",
|
52
|
+
"spec/rails/config/initializers/mime_types.rb",
|
53
|
+
"spec/rails/config/initializers/new_rails_defaults.rb",
|
54
|
+
"spec/rails/config/initializers/session_store.rb",
|
55
|
+
"spec/rails/config/locales/en.yml",
|
56
|
+
"spec/rails/config/routes.rb",
|
57
|
+
"spec/rails/db/test.sqlite3",
|
58
|
+
"spec/rcov.opts",
|
59
|
+
"spec/spec.opts",
|
60
|
+
"spec/spec_helper.rb",
|
61
|
+
"spec/tartarus/logger_spec.rb",
|
62
|
+
"spec/tartarus/rescue_spec.rb",
|
63
|
+
"spec/tartarus_spec.rb",
|
64
|
+
"tartarus.gemspec"
|
65
|
+
]
|
66
|
+
s.homepage = %q{http://github.com/dinsley/tartarus}
|
67
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
68
|
+
s.require_paths = ["lib"]
|
69
|
+
s.rubygems_version = %q{1.3.5}
|
70
|
+
s.summary = %q{Exception Logging for Rails}
|
71
|
+
s.test_files = [
|
72
|
+
"spec/rails/app/controllers/application_controller.rb",
|
73
|
+
"spec/rails/app/models/logged_exception.rb",
|
74
|
+
"spec/rails/config/boot.rb",
|
75
|
+
"spec/rails/config/environment.rb",
|
76
|
+
"spec/rails/config/environments/development.rb",
|
77
|
+
"spec/rails/config/environments/production.rb",
|
78
|
+
"spec/rails/config/environments/test.rb",
|
79
|
+
"spec/rails/config/initializers/backtrace_silencers.rb",
|
80
|
+
"spec/rails/config/initializers/inflections.rb",
|
81
|
+
"spec/rails/config/initializers/mime_types.rb",
|
82
|
+
"spec/rails/config/initializers/new_rails_defaults.rb",
|
83
|
+
"spec/rails/config/initializers/session_store.rb",
|
84
|
+
"spec/rails/config/routes.rb",
|
85
|
+
"spec/spec_helper.rb",
|
86
|
+
"spec/tartarus/logger_spec.rb",
|
87
|
+
"spec/tartarus/rescue_spec.rb",
|
88
|
+
"spec/tartarus_spec.rb"
|
89
|
+
]
|
90
|
+
|
91
|
+
if s.respond_to? :specification_version then
|
92
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
93
|
+
s.specification_version = 3
|
94
|
+
|
95
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
96
|
+
s.add_runtime_dependency(%q<will_paginate>, [">= 0"])
|
97
|
+
s.add_development_dependency(%q<rails>, [">= 0"])
|
98
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
99
|
+
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
|
100
|
+
else
|
101
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
102
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
103
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
104
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
105
|
+
end
|
106
|
+
else
|
107
|
+
s.add_dependency(%q<will_paginate>, [">= 0"])
|
108
|
+
s.add_dependency(%q<rails>, [">= 0"])
|
109
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
110
|
+
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tartarus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Insley
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-24 00:00:00 -08:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -106,6 +106,7 @@ files:
|
|
106
106
|
- spec/tartarus/logger_spec.rb
|
107
107
|
- spec/tartarus/rescue_spec.rb
|
108
108
|
- spec/tartarus_spec.rb
|
109
|
+
- tartarus.gemspec
|
109
110
|
has_rdoc: true
|
110
111
|
homepage: http://github.com/dinsley/tartarus
|
111
112
|
licenses: []
|