me_exceptional 0.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/.gitignore +3 -0
- data/Gemfile +4 -0
- data/README.rdoc +37 -0
- data/Rakefile +2 -0
- data/app/mailers/me_exceptional/mailer.rb +24 -0
- data/app/views/me_exceptional/mailer/exceptional.html.erb +53 -0
- data/lib/generators/me_exceptional/install_generator.rb +20 -0
- data/lib/generators/templates/README +4 -0
- data/lib/generators/templates/me_exceptional.rb +14 -0
- data/lib/me_exceptional/action_controller_extension.rb +31 -0
- data/lib/me_exceptional/engine.rb +11 -0
- data/lib/me_exceptional/version.rb +3 -0
- data/lib/me_exceptional.rb +23 -0
- data/me_exceptional.gemspec +27 -0
- metadata +108 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
= MeExceptional
|
4
|
+
|
5
|
+
The Gem notifies you of application exceptions by email and adds some
|
6
|
+
useful information about the request and the client issuing the request.
|
7
|
+
It is heavily inspired by the exceptional gem and takes some of it design
|
8
|
+
for the HTML email.
|
9
|
+
|
10
|
+
|
11
|
+
== Installation
|
12
|
+
|
13
|
+
Install the gem in your Rails 3 App as usual:
|
14
|
+
|
15
|
+
gem install me_exceptional
|
16
|
+
|
17
|
+
Add installation run the generator
|
18
|
+
|
19
|
+
rails generate me_exceptional:install
|
20
|
+
|
21
|
+
The generator will create an initializer which you MUST take a look at
|
22
|
+
and configure.
|
23
|
+
|
24
|
+
|
25
|
+
Support for Rails 2.x is not provided so far.
|
26
|
+
|
27
|
+
|
28
|
+
== Getting Started
|
29
|
+
|
30
|
+
So far there's nothing much more to it. In your production environment you
|
31
|
+
will get emails for controller exceptions.
|
32
|
+
|
33
|
+
=== Configuring views
|
34
|
+
|
35
|
+
Coming Soon.
|
36
|
+
|
37
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
class MeExceptional::Mailer < ::ActionMailer::Base
|
2
|
+
|
3
|
+
def exceptional(message, params)
|
4
|
+
@message, @params = message, params
|
5
|
+
@hostname = get_hostname(params[:client_ip])
|
6
|
+
@loc = geocode_ip(params[:client_ip])
|
7
|
+
mail(:from => MeExceptional.mailer_from, :to => MeExceptional.mailer_to, :subject => message)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def get_hostname(ip)
|
13
|
+
Socket.do_not_reverse_lookup = false
|
14
|
+
Socket.getaddrinfo(ip, nil)[0][2]
|
15
|
+
end
|
16
|
+
|
17
|
+
def geocode_ip(ip)
|
18
|
+
GeoKit::Geocoders::MultiGeocoder.geocode(ip)
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
|
2
|
+
<p style="font-size:12px"><b>Message</b></p>
|
3
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
4
|
+
<%= @message %>
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<p style="font-size:12px"><b>Time</b></p>
|
8
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
9
|
+
<%= @params[:timestamp] %>
|
10
|
+
</p>
|
11
|
+
|
12
|
+
<p style="font-size:12px"><b>URL</b></p>
|
13
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
14
|
+
<%= @params[:method] %> <%= @params[:url] %>
|
15
|
+
</p>
|
16
|
+
|
17
|
+
<p style="font-size:12px"><b>Params</b></p>
|
18
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
19
|
+
<%= @params[:params] %>
|
20
|
+
</p>
|
21
|
+
|
22
|
+
<p style="font-size:12px"><b>User Agent</b></p>
|
23
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
24
|
+
<%= @params[:user_agent] %>
|
25
|
+
</p>
|
26
|
+
|
27
|
+
<p style="font-size:12px"><b>Client IP</b></p>
|
28
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
29
|
+
<%= @params[:client_ip] %> (<%= @hostname %>)
|
30
|
+
</p>
|
31
|
+
|
32
|
+
<p style="font-size:12px"><b>Address</b></p>
|
33
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
34
|
+
<%= @loc.full_address %>
|
35
|
+
</p>
|
36
|
+
|
37
|
+
<p style="font-size:12px"><b>Location</b></p>
|
38
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
39
|
+
<%- query = CGI::escape([@loc.lat, @loc.lng].join(','))%>
|
40
|
+
http://maps.google.com/maps?q=<%= query %>
|
41
|
+
</p>
|
42
|
+
|
43
|
+
<p style="font-size:12px"><b>Complete Backtrace</b></p>
|
44
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
45
|
+
<%= @params[:backtrace] %>
|
46
|
+
</p>
|
47
|
+
|
48
|
+
<p style="font-size:12px"><b>Complete Request Object</b></p>
|
49
|
+
<p style="font-size:11px;font-family:Monaco,'Andale Mono',Consolas,'Courier New',monospace">
|
50
|
+
<%= @params[:request_env] %>
|
51
|
+
</p>
|
52
|
+
|
53
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module MeExceptional
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
|
+
|
7
|
+
desc "Creates a MeExceptional initializer."
|
8
|
+
|
9
|
+
def copy_initializer_file
|
10
|
+
copy_file "me_exceptional.rb", "config/initializers/me_exceptional.rb"
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_readme
|
14
|
+
readme "README" if behavior == :invoke
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
MeExceptional.setup do|config|
|
4
|
+
|
5
|
+
# Configure the e-mail address from which exceptions are to be sent
|
6
|
+
config.mailer_from = "please-change-me@example.com"
|
7
|
+
|
8
|
+
# Configure the e-mail address which will receive the exception mails
|
9
|
+
config.mailer_to = "please-change-me@example.com"
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'action_controller'
|
2
|
+
require 'action_dispatch'
|
3
|
+
|
4
|
+
module ActionController
|
5
|
+
class Base
|
6
|
+
|
7
|
+
rescue_from Exception, :with => :exception_catcher
|
8
|
+
|
9
|
+
def exception_catcher(e)
|
10
|
+
if Rails.env == 'production'
|
11
|
+
# blocking to be sure this gets send!
|
12
|
+
Emailer.exceptional(e.message,
|
13
|
+
:backtrace => e.backtrace.join("\n"),
|
14
|
+
:timestamp => Time.zone.now,
|
15
|
+
:method => request.method,
|
16
|
+
:url => request.url,
|
17
|
+
:params => params.inspect.to_s,
|
18
|
+
:user_agent => request.user_agent,
|
19
|
+
:client_ip => request.remote_ip,
|
20
|
+
:request_env => request.env.inspect.to_s).deliver
|
21
|
+
|
22
|
+
end
|
23
|
+
raise e
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module MeExceptional
|
4
|
+
|
5
|
+
mattr_accessor :mailer_from
|
6
|
+
@@mailer_from = nil
|
7
|
+
|
8
|
+
mattr_accessor :mailer_to
|
9
|
+
@@mailer_to = nil
|
10
|
+
|
11
|
+
|
12
|
+
def self.setup
|
13
|
+
yield self
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
require 'me_exceptional/action_controller_extension'
|
19
|
+
require 'me_exceptional/engine'
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "me_exceptional/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "me_exceptional"
|
7
|
+
s.version = MeExceptional::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Kai Rubarth"]
|
10
|
+
s.email = ["kai@doxter.de"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{notifies you of exceptions by email}
|
13
|
+
s.description = %q{The gem catches exceptions and creates and sends emails with backtrace and other informations.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "me_exceptional"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency('rails')
|
23
|
+
s.add_dependency('geokit')
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: me_exceptional
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Kai Rubarth
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-06-16 00:00:00 +02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rails
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: geokit
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: The gem catches exceptions and creates and sends emails with backtrace and other informations.
|
50
|
+
email:
|
51
|
+
- kai@doxter.de
|
52
|
+
executables: []
|
53
|
+
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
extra_rdoc_files: []
|
57
|
+
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- app/mailers/me_exceptional/mailer.rb
|
64
|
+
- app/views/me_exceptional/mailer/exceptional.html.erb
|
65
|
+
- lib/generators/me_exceptional/install_generator.rb
|
66
|
+
- lib/generators/templates/README
|
67
|
+
- lib/generators/templates/me_exceptional.rb
|
68
|
+
- lib/me_exceptional.rb
|
69
|
+
- lib/me_exceptional/action_controller_extension.rb
|
70
|
+
- lib/me_exceptional/engine.rb
|
71
|
+
- lib/me_exceptional/version.rb
|
72
|
+
- me_exceptional.gemspec
|
73
|
+
has_rdoc: true
|
74
|
+
homepage: ""
|
75
|
+
licenses: []
|
76
|
+
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
|
80
|
+
require_paths:
|
81
|
+
- lib
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 3
|
97
|
+
segments:
|
98
|
+
- 0
|
99
|
+
version: "0"
|
100
|
+
requirements: []
|
101
|
+
|
102
|
+
rubyforge_project: me_exceptional
|
103
|
+
rubygems_version: 1.3.7
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: notifies you of exceptions by email
|
107
|
+
test_files: []
|
108
|
+
|