lichtamberg-Lighthouse_Exception_Logger 0.0.1 → 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +0 -2
- data/lib/LighthouseExceptionLogger.rb +29 -16
- metadata +1 -1
data/README.txt
CHANGED
@@ -7,7 +7,7 @@ require 'lighthouse'
|
|
7
7
|
# Plugin for applications to automatically post errors to the Hoptoad of their choice.
|
8
8
|
module LighthouseExceptionLogger
|
9
9
|
|
10
|
-
VERSION = '0.
|
10
|
+
VERSION = '0.1'
|
11
11
|
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
12
12
|
'ActionController::RoutingError',
|
13
13
|
'ActionController::InvalidAuthenticityToken',
|
@@ -101,7 +101,7 @@ module LighthouseExceptionLogger
|
|
101
101
|
end
|
102
102
|
|
103
103
|
# This method should be used for sending manual notifications while you are still
|
104
|
-
# inside the controller. Otherwise it works like
|
104
|
+
# inside the controller. Otherwise it works like HoptoadNotifier.notify.
|
105
105
|
def notify_lighthouse hash_or_exception
|
106
106
|
if public_environment?
|
107
107
|
notice = normalize_notice(hash_or_exception)
|
@@ -127,7 +127,7 @@ module LighthouseExceptionLogger
|
|
127
127
|
end
|
128
128
|
|
129
129
|
def ignore?(exception) #:nodoc:
|
130
|
-
ignore_these =
|
130
|
+
ignore_these = HoptoadNotifier.ignore.flatten
|
131
131
|
ignore_these.include?(exception.class) || ignore_these.include?(exception.class.name)
|
132
132
|
end
|
133
133
|
|
@@ -181,16 +181,29 @@ module LighthouseExceptionLogger
|
|
181
181
|
end
|
182
182
|
|
183
183
|
def send_to_LighthouseExceptionLogger data #:nodoc:
|
184
|
-
Lighthouse.account = LIGHTHOUSE_ACCOUNT
|
185
|
-
if defined?(LIGHTHOUSE_TOKEN)
|
186
|
-
Lighthouse.token = LIGHTHOUSE_TOKEN
|
187
|
-
else
|
188
|
-
Lighthouse.authenticate(LIGHTHOUSE_USERNAME, LIGHTHOUSE_PASSWORD)
|
189
|
-
end
|
190
184
|
|
191
|
-
|
192
|
-
|
193
|
-
|
185
|
+
## Hier alles einfügen
|
186
|
+
url = HoptoadNotifier.url
|
187
|
+
Net::HTTP.start(url.host, url.port) do |http|
|
188
|
+
headers = {
|
189
|
+
'Content-type' => 'application/x-yaml',
|
190
|
+
'Accept' => 'text/xml, application/xml'
|
191
|
+
}
|
192
|
+
http.read_timeout = 5 # seconds
|
193
|
+
http.open_timeout = 2 # seconds
|
194
|
+
http.use_ssl = !!HoptoadNotifier.secure
|
195
|
+
response = begin
|
196
|
+
http.post(url.path, stringify_keys(data).to_yaml, headers)
|
197
|
+
rescue TimeoutError => e
|
198
|
+
logger.error "Timeout while contacting the Hoptoad server."
|
199
|
+
nil
|
200
|
+
end
|
201
|
+
case response
|
202
|
+
when Net::HTTPSuccess then
|
203
|
+
logger.info "Hoptoad Success: #{response.class}"
|
204
|
+
else
|
205
|
+
logger.error "Hoptoad Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
|
206
|
+
end
|
194
207
|
end
|
195
208
|
end
|
196
209
|
|
@@ -200,7 +213,7 @@ module LighthouseExceptionLogger
|
|
200
213
|
end
|
201
214
|
|
202
215
|
backtrace.to_a.map do |line|
|
203
|
-
|
216
|
+
HoptoadNotifier.backtrace_filters.inject(line) do |line, proc|
|
204
217
|
proc.call(line)
|
205
218
|
end
|
206
219
|
end
|
@@ -208,7 +221,7 @@ module LighthouseExceptionLogger
|
|
208
221
|
|
209
222
|
def clean_LighthouseExceptionLogger_params params #:nodoc:
|
210
223
|
params.each do |k, v|
|
211
|
-
params[k] = "[FILTERED]" if
|
224
|
+
params[k] = "[FILTERED]" if HoptoadNotifier.params_filters.any? do |filter|
|
212
225
|
k.to_s.match(/#{filter}/)
|
213
226
|
end
|
214
227
|
end
|
@@ -216,7 +229,7 @@ module LighthouseExceptionLogger
|
|
216
229
|
|
217
230
|
def clean_LighthouseExceptionLogger_environment env #:nodoc:
|
218
231
|
env.each do |k, v|
|
219
|
-
env[k] = "[FILTERED]" if
|
232
|
+
env[k] = "[FILTERED]" if HoptoadNotifier.environment_filters.any? do |filter|
|
220
233
|
k.to_s.match(/#{filter}/)
|
221
234
|
end
|
222
235
|
end
|
@@ -247,6 +260,6 @@ module LighthouseExceptionLogger
|
|
247
260
|
def rescue_action_in_public(exception)
|
248
261
|
end
|
249
262
|
|
250
|
-
include
|
263
|
+
include HoptoadNotifier::Catcher
|
251
264
|
end
|
252
265
|
end
|