slack_500 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/slack_500/version.rb +1 -1
- data/lib/slack_500.rb +44 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf51440f0ff4a45dc0bc36864fd1a89aaf52d92986d7ebcb5ccae8828e81c892
|
4
|
+
data.tar.gz: 758993a70ff1e51e5d843a0c56e61bae41a2bc607a46d92d67d7bf5784fceeb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05cb0dc736b454453980c53df548907a82fb87d7bec6f8454e483d0be4281f141e6ac56edfe711f1d088415d16604713a3298f56fe99cf3e80405b4a42011125
|
7
|
+
data.tar.gz: 0ead63383d654a527988c2ae2d82b2d7a5f0b57cc998b2ec0de53e18068080ff29a53a3b091e877290e40848d24c2bff05e0bb56f4cabb3bb4d720b3386e8fc7
|
data/README.md
CHANGED
@@ -6,12 +6,13 @@ The following items are displayed in the Slack message.
|
|
6
6
|
|
7
7
|
- http method
|
8
8
|
- Controller and Action
|
9
|
-
- Parameters
|
9
|
+
- Query Parameters
|
10
|
+
- Remote IP
|
10
11
|
- User Agent
|
11
12
|
- Error Message
|
12
13
|
- Backtrace
|
13
14
|
|
14
|
-
<img src="https://user-images.githubusercontent.com/2704723/
|
15
|
+
<img src="https://user-images.githubusercontent.com/2704723/60161177-ee479980-9831-11e9-9861-360ce28ffdef.png" width="70%"/>
|
15
16
|
|
16
17
|
|
17
18
|
## Installation
|
data/lib/slack_500/version.rb
CHANGED
data/lib/slack_500.rb
CHANGED
@@ -47,8 +47,45 @@ module Slack500
|
|
47
47
|
return
|
48
48
|
end
|
49
49
|
|
50
|
-
|
50
|
+
bullet = ':black_small_square:'
|
51
|
+
text = "#{exception.message}\n\n"
|
51
52
|
|
53
|
+
text += "#{bullet}*Request*\n*#{request.method}* #{request.url}\n\n"
|
54
|
+
text += "#{bullet}*User Agent*\n#{request.user_agent}\n\n"
|
55
|
+
text += "#{bullet}*IP*\n#{request.remote_ip}\n\n"
|
56
|
+
text += "#{bullet}*Query*\n#{request.query_parameters}\n\n" unless request.query_parameters.empty?
|
57
|
+
|
58
|
+
request.body.rewind
|
59
|
+
body_text = request.body.read
|
60
|
+
|
61
|
+
begin
|
62
|
+
if body_text.present?
|
63
|
+
body = JSON.parse(body_text)
|
64
|
+
end
|
65
|
+
rescue => e
|
66
|
+
if body_text.present?
|
67
|
+
body_params = {}
|
68
|
+
body_text.split('&').each do |param|
|
69
|
+
kv = param.split("=")
|
70
|
+
if kv.length == 2
|
71
|
+
if kv[0].downcase.index('token').present? || kv[0].downcase.index('password').present?
|
72
|
+
body_params[URI.decode(kv[0])] = '[** FILTERED **]'
|
73
|
+
elsif kv[0] != 'utf8'
|
74
|
+
body_params[URI.decode(kv[0])] = truncate(URI.decode(kv[1]).force_encoding('UTF-8'),100)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
if body_params.empty?
|
79
|
+
body = body_text
|
80
|
+
else
|
81
|
+
body = body_params
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
text += "#{bullet}*Body*\n#{body}\n\n" unless body.nil?
|
87
|
+
text += "#{bullet}:*Backtrace*\n#{exception.backtrace.map {|s| "`#{s.gsub('`', '').gsub("'", '').gsub(Rails.root.to_s, '')}`"}.join("\n")}"
|
88
|
+
text = text.force_encoding('UTF-8')
|
52
89
|
default_params = {
|
53
90
|
pretext: self.pretext,
|
54
91
|
title: self.title,
|
@@ -76,4 +113,10 @@ module Slack500
|
|
76
113
|
Rails.logger.error "** Slack500:: #{e.full_message}."
|
77
114
|
end
|
78
115
|
end
|
116
|
+
|
117
|
+
private
|
118
|
+
def self.truncate(string, max)
|
119
|
+
string.length > max ? "#{string[0...max]}..." : string
|
120
|
+
end
|
121
|
+
|
79
122
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_500
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuo Matsunaga
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|