exception_notification-slacky 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/exception_notification-slacky.gemspec +2 -2
- data/lib/exception_notification/slacky/version.rb +1 -1
- data/lib/exception_notifier/slacky_notifier.rb +50 -32
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17159e3bc74692a2ac72c58c71ba6972c91313ce
|
4
|
+
data.tar.gz: 14568b0f398ea7dde045ffc6cfc2a6235cc2071f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 746163bf6d4776381fff1d50778584e955d1a17dda74ea118450681c1a8bd60d1f14f70b1718291231d4a28c023aa5e2fc064904ce995c4afa80afddaf6fd88c
|
7
|
+
data.tar.gz: ba9b5db8f03ab82a6c330a7c012dfb2b20a51b434b59e68a4fe2c47d6a06533697f24f051737ca4faff0ebedac000f587396ddd62cbfffddd627d9fd28acfe33
|
data/README.md
CHANGED
@@ -36,9 +36,17 @@ add below lines to config/initializers/exception_notification.rb.
|
|
36
36
|
channel: 'channel you want to being notified to',
|
37
37
|
username: 'slacky',
|
38
38
|
color: :danger, # optional, default to :danger
|
39
|
-
|
39
|
+
additional_parameters: {
|
40
40
|
icon_emoji: ':warning:'
|
41
|
-
}
|
41
|
+
},
|
42
|
+
custom_fields: [
|
43
|
+
{
|
44
|
+
title: 'User Agent',
|
45
|
+
value: ->(req) { req.user_agent },
|
46
|
+
short: false,
|
47
|
+
after: 'IP Address'
|
48
|
+
}
|
49
|
+
]
|
42
50
|
}
|
43
51
|
```
|
44
52
|
|
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "exception_notification-slacky"
|
8
8
|
spec.version = ExceptionNotification::Slacky::VERSION
|
9
9
|
spec.licenses = ['MIT']
|
10
|
-
spec.authors = ["森井ゴンザレス"]
|
11
|
-
spec.email = ["morygonzalez@gmail.com"]
|
10
|
+
spec.authors = ["森井ゴンザレス", "Ryutaro Mizokami"]
|
11
|
+
spec.email = ["morygonzalez@gmail.com", "r.mizokami@gmail.com"]
|
12
12
|
|
13
13
|
spec.summary = %q{Send Exception notification to slack}
|
14
14
|
spec.description = %q{Send Exception notification to slack. Works as ExceptionNotification Plugin.}
|
@@ -7,6 +7,7 @@ module ExceptionNotifier
|
|
7
7
|
webhook_url = options.fetch(:webhook_url)
|
8
8
|
@color = options.fetch(:color, :danger)
|
9
9
|
@message_opts = options.fetch(:additional_parameters, {})
|
10
|
+
@custom_fields = options.fetch(:custom_fields, [])
|
10
11
|
@notifier = Slack::Notifier.new(webhook_url, options)
|
11
12
|
rescue
|
12
13
|
@notifier = nil
|
@@ -40,39 +41,56 @@ module ExceptionNotifier
|
|
40
41
|
fallback: "#{exception.class} #{exception.message}",
|
41
42
|
color: @color.to_s,
|
42
43
|
title: "[ERROR] #{exception.class}",
|
43
|
-
fields:
|
44
|
-
{
|
45
|
-
title: "Host",
|
46
|
-
value: (Socket.gethostname rescue nil),
|
47
|
-
short: true
|
48
|
-
},
|
49
|
-
{
|
50
|
-
title: "Request path",
|
51
|
-
value: @request.path_info,
|
52
|
-
short: true
|
53
|
-
},
|
54
|
-
{
|
55
|
-
title: "HTTP Method",
|
56
|
-
value: @request.request_method,
|
57
|
-
short: true
|
58
|
-
},
|
59
|
-
{
|
60
|
-
title: "IP Address",
|
61
|
-
value: @request.ip,
|
62
|
-
short: true
|
63
|
-
},
|
64
|
-
{
|
65
|
-
title: "Occurred on",
|
66
|
-
value: (exception.backtrace.first rescue nil),
|
67
|
-
short: false
|
68
|
-
},
|
69
|
-
{
|
70
|
-
title: "Error message",
|
71
|
-
value: exception.message,
|
72
|
-
short: false
|
73
|
-
}
|
74
|
-
]
|
44
|
+
fields: build_fields(exception)
|
75
45
|
}
|
76
46
|
end
|
47
|
+
|
48
|
+
def build_fields(exception)
|
49
|
+
fields = [
|
50
|
+
{
|
51
|
+
title: "Host",
|
52
|
+
value: (Socket.gethostname rescue nil),
|
53
|
+
short: true
|
54
|
+
},
|
55
|
+
{
|
56
|
+
title: "Request path",
|
57
|
+
value: @request.path_info,
|
58
|
+
short: true
|
59
|
+
},
|
60
|
+
{
|
61
|
+
title: "HTTP Method",
|
62
|
+
value: @request.request_method,
|
63
|
+
short: true
|
64
|
+
},
|
65
|
+
{
|
66
|
+
title: "IP Address",
|
67
|
+
value: @request.ip,
|
68
|
+
short: true
|
69
|
+
},
|
70
|
+
{
|
71
|
+
title: "Occurred on",
|
72
|
+
value: (exception.backtrace.first rescue nil),
|
73
|
+
short: false
|
74
|
+
},
|
75
|
+
{
|
76
|
+
title: "Error message",
|
77
|
+
value: exception.message,
|
78
|
+
short: false
|
79
|
+
}
|
80
|
+
]
|
81
|
+
|
82
|
+
@custom_fields.each do |custom_field|
|
83
|
+
field = {
|
84
|
+
title: custom_field[:title],
|
85
|
+
value: custom_field[:value].call(@request),
|
86
|
+
short: custom_field[:short]
|
87
|
+
}
|
88
|
+
i = fields.index {|f| f[:title] == custom_field[:after]}
|
89
|
+
i = i ? i.succ : -1
|
90
|
+
fields.insert(i, field)
|
91
|
+
end
|
92
|
+
|
93
|
+
fields
|
94
|
+
end
|
77
95
|
end
|
78
96
|
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exception_notification-slacky
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "森井ゴンザレス"
|
8
|
+
- Ryutaro Mizokami
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
+
date: 2015-12-13 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: exception_notification
|
@@ -112,6 +113,7 @@ description: Send Exception notification to slack. Works as ExceptionNotificatio
|
|
112
113
|
Plugin.
|
113
114
|
email:
|
114
115
|
- morygonzalez@gmail.com
|
116
|
+
- r.mizokami@gmail.com
|
115
117
|
executables: []
|
116
118
|
extensions: []
|
117
119
|
extra_rdoc_files: []
|
@@ -149,8 +151,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
149
151
|
version: '0'
|
150
152
|
requirements: []
|
151
153
|
rubyforge_project:
|
152
|
-
rubygems_version: 2.
|
154
|
+
rubygems_version: 2.5.1
|
153
155
|
signing_key:
|
154
156
|
specification_version: 4
|
155
157
|
summary: Send Exception notification to slack
|
156
158
|
test_files: []
|
159
|
+
has_rdoc:
|