slack_webhook_logger 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +13 -3
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/generators/templates/slack_webhook_logger.rb +4 -0
- data/lib/slack_webhook_logger/formatter.rb +9 -4
- data/lib/slack_webhook_logger/request_io.rb +1 -1
- data/lib/slack_webhook_logger/version.rb +1 -1
- data/lib/slack_webhook_logger.rb +2 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83b1e6053d5d56948daf29d6fb73bbff0bac8a16c2c00d39eaeed2058e85015f
|
4
|
+
data.tar.gz: f88d270cc93af6de1034fa09168853b137c31b4679fbfc8e376a718e88aea47d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 825657fb963061c8c64bc2f614d07785de5c33837ab959351b34feb0b7405558af771e52846de3fe1d22b7ed7a847102a2f5853feff373e951a9f360dff934dc
|
7
|
+
data.tar.gz: aaae0faa6d0e9aa69b6dee863be0d121f440d7debcc6fe269973753088c4ed2643df1b75839b40ebc987bf92db5282bd4b1e3cad3a225933286eaa1ab5b54f24
|
data/.github/dependabot.yml
CHANGED
@@ -3,15 +3,25 @@ updates:
|
|
3
3
|
- package-ecosystem: "github-actions"
|
4
4
|
directory: "/"
|
5
5
|
schedule:
|
6
|
-
interval:
|
6
|
+
interval: weekly
|
7
|
+
day: monday
|
7
8
|
time: "09:00"
|
8
9
|
timezone: "Etc/UTC"
|
10
|
+
groups:
|
11
|
+
github-actions:
|
12
|
+
patterns:
|
13
|
+
- "*"
|
9
14
|
open-pull-requests-limit: 10
|
10
15
|
|
11
|
-
- package-ecosystem:
|
16
|
+
- package-ecosystem: bundler
|
12
17
|
directory: "/"
|
13
18
|
schedule:
|
14
|
-
interval:
|
19
|
+
interval: weekly
|
20
|
+
day: monday
|
15
21
|
time: "09:00"
|
16
22
|
timezone: "Etc/UTC"
|
17
23
|
open-pull-requests-limit: 10
|
24
|
+
groups:
|
25
|
+
bundler-dependencies:
|
26
|
+
patterns:
|
27
|
+
- "*"
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## [v0.5.5] - 16-08-2023
|
2
|
+
## What's Changed
|
3
|
+
* Changes for new char limits by @gjtorikian in https://github.com/gjtorikian/slack_webhook_logger/pull/15
|
4
|
+
|
5
|
+
|
6
|
+
**Full Changelog**: https://github.com/gjtorikian/slack_webhook_logger/compare/v0.5.4...v0.5.5
|
7
|
+
## [v0.5.4] - 06-07-2023
|
8
|
+
null
|
1
9
|
## [v0.5.2] - 06-07-2023
|
2
10
|
null
|
3
11
|
## [v0.5.1] - 06-07-2023
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ end
|
|
38
38
|
|
39
39
|
## Configuration
|
40
40
|
|
41
|
-
You should have a file in `config/initializers/slack_webhook_logger.rb` that looks
|
41
|
+
You should have a file in `config/initializers/slack_webhook_logger.rb` that looks something like this:
|
42
42
|
|
43
43
|
```ruby
|
44
44
|
SlackWebhookLogger.setup do |config|
|
@@ -18,4 +18,8 @@ SlackWebhookLogger.setup do |config|
|
|
18
18
|
# You can provide an array of regular expressions to ignore certain messages
|
19
19
|
# from being sent to Slack. This is optional.
|
20
20
|
# config.ignore_patterns = []
|
21
|
+
|
22
|
+
# You can provide a specific name for your app; otherwise, it will default to
|
23
|
+
# the name of your Rails app. This is optional.
|
24
|
+
# config.application_name = []
|
21
25
|
end
|
@@ -4,7 +4,13 @@ module SlackWebhookLogger
|
|
4
4
|
class Formatter < ::Logger::Formatter
|
5
5
|
attr_writer :format
|
6
6
|
|
7
|
-
MAX_LENGTH =
|
7
|
+
MAX_LENGTH = 3000
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def fetch_text(hash)
|
11
|
+
hash[:blocks].last[:text][:text]
|
12
|
+
end
|
13
|
+
end
|
8
14
|
|
9
15
|
def format
|
10
16
|
@format ||= proc do |severity, time, _progname, msg|
|
@@ -23,7 +29,7 @@ module SlackWebhookLogger
|
|
23
29
|
"🪵 *Logger*"
|
24
30
|
end
|
25
31
|
|
26
|
-
title = "#{heading}
|
32
|
+
title = "#{heading} #{SlackWebhookLogger.application_name} [#{ENV.fetch("RAILS_ENV", nil)}] (#{time})"
|
27
33
|
|
28
34
|
text = <<~MSG
|
29
35
|
#{msg2str(msg)}
|
@@ -39,7 +45,6 @@ module SlackWebhookLogger
|
|
39
45
|
|
40
46
|
def slackify(title, text)
|
41
47
|
{
|
42
|
-
text: [title, text].join("\n").to_s,
|
43
48
|
blocks: [
|
44
49
|
{
|
45
50
|
type: "section",
|
@@ -75,7 +80,7 @@ module SlackWebhookLogger
|
|
75
80
|
end
|
76
81
|
|
77
82
|
private def truncate(string)
|
78
|
-
string.length > MAX_LENGTH ? "#{string[0...MAX_LENGTH]}..." : string
|
83
|
+
string.length > MAX_LENGTH ? "#{string[0...MAX_LENGTH - 3]}..." : string
|
79
84
|
end
|
80
85
|
end
|
81
86
|
end
|
@@ -14,7 +14,7 @@ module SlackWebhookLogger
|
|
14
14
|
def write(hash)
|
15
15
|
return if hash.blank?
|
16
16
|
|
17
|
-
return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash
|
17
|
+
return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| SlackWebhookLogger::Formatter.fetch_text(hash).match(ignore_pattern) }
|
18
18
|
|
19
19
|
response = HTTPX.with(headers: { "content-type" => "application/json" }).post(SlackWebhookLogger.webhook_uri.to_s, json: hash)
|
20
20
|
|
data/lib/slack_webhook_logger.rb
CHANGED
@@ -17,6 +17,7 @@ module SlackWebhookLogger
|
|
17
17
|
mattr_accessor :level
|
18
18
|
mattr_accessor :formatter
|
19
19
|
mattr_accessor :ignore_patterns
|
20
|
+
mattr_accessor :application_name
|
20
21
|
|
21
22
|
# Used internally
|
22
23
|
mattr_reader :webhook_uri
|
@@ -39,6 +40,7 @@ module SlackWebhookLogger
|
|
39
40
|
raise ArgumentError, "Invalid URI for webhook_url"
|
40
41
|
end
|
41
42
|
|
43
|
+
@@application_name ||= Rails.application.class.module_parent_name
|
42
44
|
@@ignore_patterns ||= []
|
43
45
|
end
|
44
46
|
# rubocop:enable Style/ClassVars
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slack_webhook_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Garen J. Torikian
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-08-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
requirements: []
|
123
|
-
rubygems_version: 3.4.
|
123
|
+
rubygems_version: 3.4.19
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: A slim wrapper for posting to Rails logs to Slack
|