slack-logger 0.4.1 → 0.5.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c955e77aba2b4fe3ac9f7cc757b1abf72f58893
4
- data.tar.gz: 4efe7641a02fb280e55316695cb516af64510337
3
+ metadata.gz: e56e50d1d6de2b85c2f0b2ab40e9d9665d62971c
4
+ data.tar.gz: c9cda422bd864c35ddd04a7204fc0a18aa383d55
5
5
  SHA512:
6
- metadata.gz: 317b18b39e03a0dae340796b2a205b0e20fdce06fb892f3d3e839dc0807595c4e9ee55907a4abfb8465367e0d658631032382546aa961746362e44d4505cbded
7
- data.tar.gz: ec355a698e89edee17fd120988eff0d5a5adac1fcbc8f3a6799cbdfc72597e884e37c0a8acea6166f92769db610cda0fb8a270b8e0e57eaad6b5b554219f6b46
6
+ metadata.gz: 18237ec9b7a9c4531cd1b1aaf555ab843f0e1e60bc33a702ca1b0e1cf6f9065575b33d296789a87483371c44445a62b1e78d5e64d59ac2256430ee8db9c5428c
7
+ data.tar.gz: 1651ce4c5486248732fbbf60dcf15cd65f16b3d903cc12344355b8a1f457dffe6cffe461ff0733715cf6a392a05122885ad106669c22726eabca556502971f0c
@@ -28,6 +28,34 @@ SlackLogger.setup do |config|
28
28
  # config.client = Slack::Web::Client.new(:token => Rails.application.secrets.slack_api_token)
29
29
 
30
30
 
31
+ ## Slack Format
32
+ # ------------
33
+ #
34
+ # The format of the message you would like to appear on slack. By default it is set to:
35
+ # Proc.new { |severity, datetime, _progname, msg |
36
+ # {
37
+ # channel: SlackLogger.channel,
38
+ # attachments: [{
39
+ # pretext: msg.to_s,
40
+ # ts: "#{datetime}",
41
+ # fields: [
42
+ # {
43
+ # title: "Project",
44
+ # value: "#{Rails.application.class.parent_name}",
45
+ # short: true
46
+ # },
47
+ # {
48
+ # title: "Environment",
49
+ # value: "#{Rails.env}",
50
+ # short: true
51
+ # }
52
+ # ],
53
+ # color: "#F35A00"
54
+ # }].to_json,
55
+ # as_user: true}
56
+ # }
57
+ # config.logger.formatter = SlackLogger::Formatter.new.format = -> {}
58
+
31
59
  ## Slack Channel
32
60
  # -------------
33
61
  #
@@ -0,0 +1,37 @@
1
+ module SlackLogger
2
+ class Formatter < ::Logger::Formatter
3
+
4
+ attr_accessor :format
5
+
6
+ def initialize
7
+ super
8
+ end
9
+
10
+ def format
11
+ @format ||= Proc.new { | severity, time, _progname, msg | { channel: SlackLogger.channel,
12
+ attachments: [{
13
+ pretext: msg.to_s,
14
+ ts: "#{time.to_i}",
15
+ fields: [
16
+ {
17
+ title: "Project",
18
+ value: "#{Rails.application.class.parent_name}",
19
+ short: true
20
+ },
21
+ {
22
+ title: "Environment",
23
+ value: "#{Rails.env}",
24
+ short: true
25
+ }
26
+ ],
27
+ color: "#F35A00"
28
+ }].to_json,
29
+ as_user: true
30
+ }}
31
+ end
32
+
33
+ def call(severity, time, progname, msg)
34
+ format.call(severity, time, progname, msg)
35
+ end
36
+ end
37
+ end
@@ -9,26 +9,7 @@ module SlackLogger
9
9
  unless message.blank?
10
10
  client = SlackLogger.client
11
11
  client.auth_test
12
- client.chat_postMessage({
13
- channel: SlackLogger.channel,
14
- attachments: [{
15
- pretext: message.to_s,
16
- ts: "#{Time.now.utc.to_i}",
17
- fields: [
18
- {
19
- title: "Project",
20
- value: "#{Rails.application.class.parent_name}",
21
- short: true
22
- },
23
- {
24
- title: "Environment",
25
- value: "#{Rails.env}",
26
- short: true
27
- }
28
- ],
29
- color: "#F35A00"
30
- }].to_json,
31
- as_user: true})
12
+ client.chat_postMessage(message)
32
13
  end
33
14
  end
34
15
 
@@ -1,3 +1,3 @@
1
1
  module SlackLogger
2
- VERSION = '0.4.1'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slack-logger
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - josephverbeck
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-22 00:00:00.000000000 Z
11
+ date: 2017-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,6 +114,7 @@ files:
114
114
  - lib/generators/templates/slack_logger.rb
115
115
  - lib/slack-logger.rb
116
116
  - lib/slack_logger/engine.rb
117
+ - lib/slack_logger/formatter.rb
117
118
  - lib/slack_logger/logger.rb
118
119
  - lib/slack_logger/slack_io.rb
119
120
  - lib/slack_logger/version.rb
@@ -138,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  version: '0'
139
140
  requirements: []
140
141
  rubyforge_project:
141
- rubygems_version: 2.5.1
142
+ rubygems_version: 2.4.5
142
143
  signing_key:
143
144
  specification_version: 4
144
145
  summary: Simple rails plugin that sends error messages to slack