14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/exception_notification_line_notify.rb', line 14
def call(exception, options={})
@request = ActionDispatch::Request.new(options[:env])
@backtrace = exception.backtrace.first
@exception_message = exception.message
@request_section = {
parameters: @request.filtered_parameters.inspect,
method: @request.request_method,
ip: @request.remote_ip,
root: Rails.root.to_s,
}.map{|k, v| "[#{k}] \n#{v}"}.join("\n")
@session_section = @request.session.to_hash.inspect
@message = %Q(
\n #{@request.url}
\n #{@backtrace}
\n======Request=====
\n#{@request_section}
\n======Session=====
\n#{@session_section}
)
if @line_notify_token
begin
@response = RestClient.post 'https://notify-api.line.me/api/notify', {message: @message}, { :Authorization => "Bearer #{@line_notify_token}"}
rescue => e
puts e
end
end
end
|