prowl-exception 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/lib/prowl_exception/rack.rb +41 -0
- data/lib/prowl_exception.rb +9 -0
- data/prowl-exception.gemspec +16 -0
- metadata +64 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'rack'
|
2
|
+
require 'prowler'
|
3
|
+
|
4
|
+
module Rack
|
5
|
+
class ProwlException
|
6
|
+
|
7
|
+
def initialize app
|
8
|
+
@app = app
|
9
|
+
@template = ERB.new(TEMPLATE)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
begin
|
14
|
+
body = @app.call(env)
|
15
|
+
rescue => boom
|
16
|
+
send_prowl_notification boom, env
|
17
|
+
raise
|
18
|
+
end
|
19
|
+
|
20
|
+
body
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def send_prowl_notification exception, env
|
26
|
+
request = Rack::Request.new env
|
27
|
+
Prowler.notify exception.class.to_s, @template.result(binding)
|
28
|
+
end
|
29
|
+
|
30
|
+
TEMPLATE = (<<-'BODY').gsub(/^ {4}/, '')
|
31
|
+
A <%= exception.class.to_s %> occured: <%= exception.to_s %>
|
32
|
+
|
33
|
+
<%= request.respond_to?(:remote_ip) ? request.remote_ip : request.ip %> => <%= request.request_method %> <%= request.respond_to?(:url) ? request.url : "#{request.protocol}#{request.host}#{request.request_uri}" %> => <%= env['action_controller.instance'].class.to_s %>#<%= request.respond_to?(:parameters) ? request.parameters['action'] : request.params['action'] %> with <%= request.respond_to?(:parameters) ? request.parameters : request.params %>
|
34
|
+
<%= request.env.select{|k,v| k.start_with? 'HTTP' }.map{|k,v| "#{k} => #{v}" }.join("\n") %>
|
35
|
+
<% if exception.respond_to?(:backtrace) %>
|
36
|
+
<%= exception.backtrace.take(5).join("\n") %>
|
37
|
+
<% end %>
|
38
|
+
BODY
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.authors = %w{ Afhbl }
|
3
|
+
s.email = %w{ farid@bagishev.ru }
|
4
|
+
|
5
|
+
s.name = 'prowl-exception'
|
6
|
+
s.summary = "Send exception summary to prowl"
|
7
|
+
s.description = %w{ Send exception summary to prowl }
|
8
|
+
s.homepage = 'https://github.com/afhbl/prowl-exception'
|
9
|
+
|
10
|
+
s.version = '0.0.1'
|
11
|
+
s.date = '2012-08-01'
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
s.add_runtime_dependency 'prowler', '~> 1.2'
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prowl-exception
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Afhbl
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: prowler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.2'
|
30
|
+
description: ! '["Send", "exception", "summary", "to", "prowl"]'
|
31
|
+
email:
|
32
|
+
- farid@bagishev.ru
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- lib/prowl_exception.rb
|
38
|
+
- lib/prowl_exception/rack.rb
|
39
|
+
- prowl-exception.gemspec
|
40
|
+
homepage: https://github.com/afhbl/prowl-exception
|
41
|
+
licenses: []
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ! '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
requirements: []
|
59
|
+
rubyforge_project:
|
60
|
+
rubygems_version: 1.8.23
|
61
|
+
signing_key:
|
62
|
+
specification_version: 3
|
63
|
+
summary: Send exception summary to prowl
|
64
|
+
test_files: []
|