slack_webhook_logger 0.3.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 +4 -4
- data/.github/FUNDING.yml +0 -9
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/automerge.yml +14 -0
- data/.github/workflows/lint.yml +12 -10
- data/.github/workflows/release.yml +19 -0
- data/.github/workflows/test.yml +22 -0
- data/.rubocop.yml +0 -3
- data/.ruby-version +1 -0
- data/.vscode/settings.json +8 -0
- data/CHANGELOG.md +2 -0
- data/Gemfile +10 -7
- data/Gemfile.lock +92 -60
- data/README.md +27 -3
- data/Rakefile +12 -8
- data/lib/generators/slack_webhook_logger/install_generator.rb +3 -3
- data/lib/generators/templates/slack_webhook_logger.rb +1 -1
- data/lib/slack_webhook_logger/formatter.rb +26 -26
- data/lib/slack_webhook_logger/logger.rb +9 -3
- data/lib/slack_webhook_logger/request_io.rb +20 -12
- data/lib/slack_webhook_logger/version.rb +1 -1
- data/lib/slack_webhook_logger.rb +23 -22
- data/slack_webhook_logger.gemspec +16 -15
- metadata +28 -8
- data/.github/workflows/ci.yml +0 -28
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a8aca45921ee3b9d9bcecb993e4b4ef9f30b7853e802babce6e0f5b208ddd2ca
|
|
4
|
+
data.tar.gz: abaf6b83376d4e412d6971b6885f2c3de02a3191f07a6ea7909aa77c5f0c99e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db1edd27e70437d26658f21caf2424b02ff3d0ca1436e56fea8888f608e8f9799b179fd61f2e63e8c3c17134d865d6796d5f66a48ac9ea3c3225152f5681630f
|
|
7
|
+
data.tar.gz: 2702fd661d5bf78050cf82033e2ea60ce65a201fa4cc28ae63bb8f8013abeac6ed7a452725231a83568c01d4032067c5e0d87b010573ac64b0beaaf37719d0d8
|
data/.github/FUNDING.yml
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
1
|
# These are supported funding model platforms
|
|
2
2
|
|
|
3
3
|
github: gjtorikian
|
|
4
|
-
patreon: gjtorikian
|
|
5
|
-
open_collective: garen-torikian
|
|
6
|
-
#ko_fi: # Replace with a single Ko-fi username
|
|
7
|
-
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
-
#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
-
#liberapay: # Replace with a single Liberapay username
|
|
10
|
-
issuehunt: gjtorikian
|
|
11
|
-
#otechie: # Replace with a single Otechie username
|
|
12
|
-
#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
version: 2
|
|
2
|
+
updates:
|
|
3
|
+
- package-ecosystem: "github-actions"
|
|
4
|
+
directory: "/"
|
|
5
|
+
schedule:
|
|
6
|
+
interval: daily
|
|
7
|
+
time: "09:00"
|
|
8
|
+
timezone: "Etc/UTC"
|
|
9
|
+
open-pull-requests-limit: 10
|
|
10
|
+
|
|
11
|
+
- package-ecosystem: "bundler"
|
|
12
|
+
directory: "/"
|
|
13
|
+
schedule:
|
|
14
|
+
interval: daily
|
|
15
|
+
time: "09:00"
|
|
16
|
+
timezone: "Etc/UTC"
|
|
17
|
+
open-pull-requests-limit: 10
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
name: "Bot auto-{approve,merge}"
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
pull_request_target:
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
pull-requests: write
|
|
9
|
+
contents: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
dependabot:
|
|
13
|
+
uses: yettoapp/actions/.github/workflows/automerge_dependabot.yml@main
|
|
14
|
+
secrets: inherit
|
data/.github/workflows/lint.yml
CHANGED
|
@@ -2,20 +2,22 @@ name: Linting
|
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
4
|
pull_request:
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
paths:
|
|
6
|
+
- "**/*.rb"
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: read
|
|
9
10
|
|
|
10
11
|
jobs:
|
|
11
|
-
|
|
12
|
+
lint:
|
|
12
13
|
runs-on: ubuntu-latest
|
|
13
14
|
steps:
|
|
14
|
-
- uses: actions/checkout@
|
|
15
|
-
|
|
15
|
+
- uses: actions/checkout@v3
|
|
16
|
+
|
|
17
|
+
- name: Set up Ruby
|
|
18
|
+
uses: yettoapp/actions/setup-languages@main
|
|
16
19
|
with:
|
|
17
|
-
ruby
|
|
18
|
-
|
|
19
|
-
- run: bundle install
|
|
20
|
+
ruby: true
|
|
21
|
+
|
|
20
22
|
- name: Rubocop
|
|
21
23
|
run: bundle exec rake rubocop
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
push:
|
|
6
|
+
branches:
|
|
7
|
+
- main
|
|
8
|
+
paths:
|
|
9
|
+
- "lib/slack_webhook_logger/version.rb"
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
ruby:
|
|
13
|
+
uses: yettoapp/actions/.github/workflows/ruby_gem_release.yml@main
|
|
14
|
+
secrets:
|
|
15
|
+
rubygems_api_key: ${{ secrets.RUBYGEMS_API_BOT_KEY }}
|
|
16
|
+
gh_token: ${{ secrets.PUBLIC_PUSH_TO_PROTECTED_BRANCH }}
|
|
17
|
+
with:
|
|
18
|
+
gem_name: slack_webhook_logger
|
|
19
|
+
version_filepath: lib/slack_webhook_logger/version.rb
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v3
|
|
15
|
+
|
|
16
|
+
- name: Set up Ruby
|
|
17
|
+
uses: yettoapp/actions/setup-languages@main
|
|
18
|
+
with:
|
|
19
|
+
ruby: true
|
|
20
|
+
|
|
21
|
+
- name: Run tests
|
|
22
|
+
run: bundle exec rake test
|
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.2.1
|
data/CHANGELOG.md
ADDED
data/Gemfile
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
source
|
|
3
|
+
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
# Specify your gem's dependencies in slack-webhooklogger.gemspec
|
|
6
6
|
gemspec
|
|
7
7
|
|
|
8
|
-
gem '
|
|
9
|
-
gem '
|
|
10
|
-
gem 'rake', '~> 12.0'
|
|
8
|
+
gem 'minitest', '~> 5.18'
|
|
9
|
+
gem 'rake', '~> 13.0'
|
|
11
10
|
gem 'rubocop', '~> 1.6'
|
|
12
|
-
gem
|
|
13
|
-
gem 'rubocop-standard', '~> 5.1'
|
|
11
|
+
gem "rubocop-standard"
|
|
14
12
|
|
|
15
|
-
gem
|
|
13
|
+
gem "webmock", "~> 3.11"
|
|
14
|
+
# mocking lib
|
|
15
|
+
gem "mocha", "~> 2.0"
|
|
16
|
+
|
|
17
|
+
gem "amazing_print", require: false
|
|
18
|
+
gem "debug", require: false
|
data/Gemfile.lock
CHANGED
|
@@ -1,124 +1,156 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
slack_webhook_logger (0.
|
|
4
|
+
slack_webhook_logger (0.5.0)
|
|
5
5
|
activesupport (>= 5.0, < 8.0)
|
|
6
|
+
httpx (~> 0.20)
|
|
6
7
|
railties (>= 5.0, < 8.0)
|
|
7
8
|
|
|
8
9
|
GEM
|
|
9
10
|
remote: https://rubygems.org/
|
|
10
11
|
specs:
|
|
11
|
-
actionpack (7.0.
|
|
12
|
-
actionview (= 7.0.
|
|
13
|
-
activesupport (= 7.0.
|
|
14
|
-
rack (~> 2.0, >= 2.2.
|
|
12
|
+
actionpack (7.0.6)
|
|
13
|
+
actionview (= 7.0.6)
|
|
14
|
+
activesupport (= 7.0.6)
|
|
15
|
+
rack (~> 2.0, >= 2.2.4)
|
|
15
16
|
rack-test (>= 0.6.3)
|
|
16
17
|
rails-dom-testing (~> 2.0)
|
|
17
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
18
|
-
actionview (7.0.
|
|
19
|
-
activesupport (= 7.0.
|
|
19
|
+
actionview (7.0.6)
|
|
20
|
+
activesupport (= 7.0.6)
|
|
20
21
|
builder (~> 3.1)
|
|
21
22
|
erubi (~> 1.4)
|
|
22
23
|
rails-dom-testing (~> 2.0)
|
|
23
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
24
|
-
activesupport (7.0.
|
|
25
|
+
activesupport (7.0.6)
|
|
25
26
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
26
27
|
i18n (>= 1.6, < 2)
|
|
27
28
|
minitest (>= 5.1)
|
|
28
29
|
tzinfo (~> 2.0)
|
|
29
|
-
addressable (2.8.
|
|
30
|
-
public_suffix (>= 2.0.2, <
|
|
30
|
+
addressable (2.8.4)
|
|
31
|
+
public_suffix (>= 2.0.2, < 6.0)
|
|
32
|
+
amazing_print (1.5.0)
|
|
31
33
|
ast (2.4.2)
|
|
32
|
-
awesome_print (1.9.2)
|
|
33
34
|
builder (3.2.4)
|
|
34
|
-
concurrent-ruby (1.
|
|
35
|
+
concurrent-ruby (1.2.2)
|
|
35
36
|
crack (0.4.5)
|
|
36
37
|
rexml
|
|
37
38
|
crass (1.0.6)
|
|
38
|
-
|
|
39
|
+
debug (1.8.0)
|
|
40
|
+
irb (>= 1.5.0)
|
|
41
|
+
reline (>= 0.3.1)
|
|
42
|
+
erubi (1.12.0)
|
|
39
43
|
hashdiff (1.0.1)
|
|
40
|
-
|
|
44
|
+
http-2-next (0.5.1)
|
|
45
|
+
httpx (0.24.1)
|
|
46
|
+
http-2-next (>= 0.4.1)
|
|
47
|
+
i18n (1.14.1)
|
|
41
48
|
concurrent-ruby (~> 1.0)
|
|
42
|
-
|
|
49
|
+
io-console (0.6.0)
|
|
50
|
+
irb (1.7.1)
|
|
51
|
+
reline (>= 0.3.0)
|
|
52
|
+
json (2.6.3)
|
|
53
|
+
language_server-protocol (3.17.0.3)
|
|
54
|
+
loofah (2.21.3)
|
|
43
55
|
crass (~> 1.0.2)
|
|
44
|
-
nokogiri (>= 1.
|
|
56
|
+
nokogiri (>= 1.12.0)
|
|
45
57
|
method_source (1.0.0)
|
|
46
|
-
minitest (5.
|
|
47
|
-
|
|
58
|
+
minitest (5.18.1)
|
|
59
|
+
mocha (2.0.4)
|
|
60
|
+
ruby2_keywords (>= 0.0.5)
|
|
61
|
+
nokogiri (1.15.3-arm64-darwin)
|
|
48
62
|
racc (~> 1.4)
|
|
49
|
-
|
|
50
|
-
|
|
63
|
+
nokogiri (1.15.3-x86_64-linux)
|
|
64
|
+
racc (~> 1.4)
|
|
65
|
+
parallel (1.23.0)
|
|
66
|
+
parser (3.2.2.3)
|
|
51
67
|
ast (~> 2.4.1)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
rack
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
68
|
+
racc
|
|
69
|
+
public_suffix (5.0.1)
|
|
70
|
+
racc (1.7.1)
|
|
71
|
+
rack (2.2.7)
|
|
72
|
+
rack-test (2.1.0)
|
|
73
|
+
rack (>= 1.3)
|
|
74
|
+
rails-dom-testing (2.1.1)
|
|
75
|
+
activesupport (>= 5.0.0)
|
|
76
|
+
minitest
|
|
59
77
|
nokogiri (>= 1.6)
|
|
60
|
-
rails-html-sanitizer (1.
|
|
61
|
-
loofah (~> 2.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
78
|
+
rails-html-sanitizer (1.6.0)
|
|
79
|
+
loofah (~> 2.21)
|
|
80
|
+
nokogiri (~> 1.14)
|
|
81
|
+
railties (7.0.6)
|
|
82
|
+
actionpack (= 7.0.6)
|
|
83
|
+
activesupport (= 7.0.6)
|
|
65
84
|
method_source
|
|
66
85
|
rake (>= 12.2)
|
|
67
86
|
thor (~> 1.0)
|
|
68
87
|
zeitwerk (~> 2.5)
|
|
69
|
-
rainbow (3.
|
|
70
|
-
rake (
|
|
71
|
-
regexp_parser (2.
|
|
88
|
+
rainbow (3.1.1)
|
|
89
|
+
rake (13.0.6)
|
|
90
|
+
regexp_parser (2.8.1)
|
|
91
|
+
reline (0.3.5)
|
|
92
|
+
io-console (~> 0.5)
|
|
72
93
|
rexml (3.2.5)
|
|
73
|
-
rubocop (1.
|
|
94
|
+
rubocop (1.54.1)
|
|
95
|
+
json (~> 2.3)
|
|
96
|
+
language_server-protocol (>= 3.17.0)
|
|
74
97
|
parallel (~> 1.10)
|
|
75
|
-
parser (>= 3.
|
|
98
|
+
parser (>= 3.2.2.3)
|
|
76
99
|
rainbow (>= 2.2.2, < 4.0)
|
|
77
100
|
regexp_parser (>= 1.8, < 3.0)
|
|
78
|
-
rexml
|
|
79
|
-
rubocop-ast (>= 1.
|
|
101
|
+
rexml (>= 3.2.5, < 4.0)
|
|
102
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
|
80
103
|
ruby-progressbar (~> 1.7)
|
|
81
|
-
unicode-display_width (>=
|
|
82
|
-
rubocop-ast (1.
|
|
83
|
-
parser (>= 3.
|
|
84
|
-
rubocop-minitest (0.
|
|
85
|
-
rubocop (>=
|
|
86
|
-
rubocop-performance (1.
|
|
104
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
|
105
|
+
rubocop-ast (1.29.0)
|
|
106
|
+
parser (>= 3.2.1.0)
|
|
107
|
+
rubocop-minitest (0.31.0)
|
|
108
|
+
rubocop (>= 1.39, < 2.0)
|
|
109
|
+
rubocop-performance (1.18.0)
|
|
87
110
|
rubocop (>= 1.7.0, < 2.0)
|
|
88
111
|
rubocop-ast (>= 0.4.0)
|
|
89
|
-
rubocop-rails (2.
|
|
112
|
+
rubocop-rails (2.20.2)
|
|
90
113
|
activesupport (>= 4.2.0)
|
|
91
114
|
rack (>= 1.1)
|
|
92
|
-
rubocop (>= 1.
|
|
115
|
+
rubocop (>= 1.33.0, < 2.0)
|
|
93
116
|
rubocop-rake (0.6.0)
|
|
94
117
|
rubocop (~> 1.0)
|
|
95
|
-
rubocop-
|
|
118
|
+
rubocop-shopify (2.14.0)
|
|
119
|
+
rubocop (~> 1.51)
|
|
120
|
+
rubocop-sorbet (0.7.0)
|
|
121
|
+
rubocop (>= 0.90.0)
|
|
122
|
+
rubocop-standard (7.1.0)
|
|
96
123
|
rubocop
|
|
97
124
|
rubocop-minitest
|
|
98
125
|
rubocop-performance
|
|
99
126
|
rubocop-rails
|
|
100
127
|
rubocop-rake
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
128
|
+
rubocop-shopify
|
|
129
|
+
rubocop-sorbet
|
|
130
|
+
ruby-progressbar (1.13.0)
|
|
131
|
+
ruby2_keywords (0.0.5)
|
|
132
|
+
thor (1.2.2)
|
|
133
|
+
tzinfo (2.0.6)
|
|
104
134
|
concurrent-ruby (~> 1.0)
|
|
105
|
-
unicode-display_width (2.
|
|
106
|
-
webmock (3.
|
|
135
|
+
unicode-display_width (2.4.2)
|
|
136
|
+
webmock (3.18.1)
|
|
107
137
|
addressable (>= 2.8.0)
|
|
108
138
|
crack (>= 0.3.2)
|
|
109
139
|
hashdiff (>= 0.4.0, < 2.0.0)
|
|
110
|
-
zeitwerk (2.
|
|
140
|
+
zeitwerk (2.6.8)
|
|
111
141
|
|
|
112
142
|
PLATFORMS
|
|
113
|
-
|
|
143
|
+
arm64-darwin-22
|
|
144
|
+
x86_64-linux
|
|
114
145
|
|
|
115
146
|
DEPENDENCIES
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
147
|
+
amazing_print
|
|
148
|
+
debug
|
|
149
|
+
minitest (~> 5.18)
|
|
150
|
+
mocha (~> 2.0)
|
|
151
|
+
rake (~> 13.0)
|
|
119
152
|
rubocop (~> 1.6)
|
|
120
|
-
rubocop-
|
|
121
|
-
rubocop-standard (~> 5.1)
|
|
153
|
+
rubocop-standard
|
|
122
154
|
slack_webhook_logger!
|
|
123
155
|
webmock (~> 3.11)
|
|
124
156
|
|
data/README.md
CHANGED
|
@@ -7,7 +7,7 @@ A simple Slack logger using ActiveSupport broadcast and a slim HTTPS call.
|
|
|
7
7
|
Add this line to your application's Gemfile:
|
|
8
8
|
|
|
9
9
|
```ruby
|
|
10
|
-
gem '
|
|
10
|
+
gem 'slack_webhook_logger'
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
And then execute:
|
|
@@ -19,13 +19,13 @@ $ bundle install
|
|
|
19
19
|
Or install it yourself as:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
$ gem install
|
|
22
|
+
$ gem install slack_webhook_logger
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
Then, run the install generator:
|
|
26
26
|
|
|
27
27
|
```
|
|
28
|
-
$ rails generate
|
|
28
|
+
$ rails generate slack_webhook_logger:install
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
Provide the webhook URL in the config, and finally, extend the logger:
|
|
@@ -38,4 +38,28 @@ end
|
|
|
38
38
|
|
|
39
39
|
## Configuration
|
|
40
40
|
|
|
41
|
+
You should have a file in `config/initializers/slack_webhook_logger.rb` that looks somrthing like this:
|
|
42
|
+
|
|
43
|
+
```ruby
|
|
44
|
+
SlackWebhookLogger.setup do |config|
|
|
45
|
+
# The URL where messages will be sent. This is required.
|
|
46
|
+
config.webhook_url = 'https://hooks.slack.com/services/xxx/yyy/zzz'
|
|
47
|
+
|
|
48
|
+
# The minimum error level to see in Slack. This is optional; the default is :WARN.
|
|
49
|
+
#
|
|
50
|
+
# All log levels are supported, but don't rely on anything less then :WARN
|
|
51
|
+
# since Slack only allows one message per minute.
|
|
52
|
+
# config.level = :WARN
|
|
53
|
+
|
|
54
|
+
# You can provide a custom log formatter if you want to. This is optional.
|
|
55
|
+
# The formatter must construct a JSON blob that adheres to Slack's expected
|
|
56
|
+
# POST payload for `chat.postMessage`: https://api.slack.com/methods/chat.postMessage
|
|
57
|
+
# config.formatter = SomeOtherFormatter.new
|
|
58
|
+
|
|
59
|
+
# You can provide an array of regular expressions to ignore certain messages
|
|
60
|
+
# from being sent to Slack. This is optional.
|
|
61
|
+
# config.ignore_patterns = []
|
|
62
|
+
end
|
|
63
|
+
```
|
|
64
|
+
|
|
41
65
|
You can change the log level or the format of the logging text if you wish. See the generated slack_webhook_logger.rb file for more information on that.
|
data/Rakefile
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "rubygems/package_task"
|
|
5
|
+
require "rake/testtask"
|
|
5
6
|
|
|
6
7
|
Rake::TestTask.new(:test) do |t|
|
|
7
|
-
t.libs <<
|
|
8
|
-
t.libs <<
|
|
9
|
-
t.test_files = FileList[
|
|
8
|
+
t.libs << "test"
|
|
9
|
+
t.libs << "lib"
|
|
10
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
|
10
11
|
end
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
require "rubocop/rake_task"
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
RuboCop::RakeTask.new
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
GEMSPEC = Bundler.load_gemspec("slack_webhook_logger.gemspec")
|
|
18
|
+
gem_path = Gem::PackageTask.new(GEMSPEC).define
|
|
19
|
+
desc "Package the ruby gem"
|
|
20
|
+
task "package" => [gem_path]
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rails/generators/base"
|
|
4
4
|
|
|
5
5
|
module SlackWebhookLogger
|
|
6
6
|
class InstallGenerator < Rails::Generators::Base
|
|
7
7
|
source_root File.expand_path("..#{File::SEPARATOR}..#{File::SEPARATOR}templates", __FILE__)
|
|
8
8
|
|
|
9
|
-
desc
|
|
9
|
+
desc "Create a Slack::WebhookLogger initializer"
|
|
10
10
|
|
|
11
11
|
def copy_initializer
|
|
12
|
-
template
|
|
12
|
+
template("slack_webhook_logger.rb", "config/initializers/slack_webhook_logger.rb")
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
SlackWebhookLogger.setup do |config|
|
|
4
4
|
# The URL where messages will be sent. This is required.
|
|
5
|
-
config.webhook_url =
|
|
5
|
+
config.webhook_url = "https://hooks.slack.com/services/xxx/yyy/zzz"
|
|
6
6
|
|
|
7
7
|
# The minimum error level to see in Slack. This is optional; the default is :WARN.
|
|
8
8
|
#
|
|
@@ -7,21 +7,21 @@ module SlackWebhookLogger
|
|
|
7
7
|
def format
|
|
8
8
|
@format ||= proc do |severity, time, _progname, msg|
|
|
9
9
|
heading = case severity
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
when "FATAL"
|
|
11
|
+
"📛 *#{severity}*"
|
|
12
|
+
when "ERROR"
|
|
13
|
+
"🛑 *#{severity}*"
|
|
14
|
+
when "WARN"
|
|
15
|
+
"⚠️ *#{severity}*"
|
|
16
|
+
when "INFO"
|
|
17
|
+
"ℹ️ *#{severity}*"
|
|
18
|
+
when "DEBUG"
|
|
19
|
+
"🐛 *#{severity}*"
|
|
20
|
+
else
|
|
21
|
+
"🪵 *Logger*"
|
|
22
|
+
end
|
|
23
23
|
|
|
24
|
-
title = "#{heading} (#{time}) [#{ENV
|
|
24
|
+
title = "#{heading} (#{time}) [#{ENV.fetch("RAILS_ENV", nil)}]"
|
|
25
25
|
|
|
26
26
|
text = <<~MSG
|
|
27
27
|
#{msg2str(msg)}
|
|
@@ -40,23 +40,23 @@ module SlackWebhookLogger
|
|
|
40
40
|
text: [title, text].join("\n").to_s,
|
|
41
41
|
blocks: [
|
|
42
42
|
{
|
|
43
|
-
type:
|
|
43
|
+
type: "section",
|
|
44
44
|
text: {
|
|
45
|
-
type:
|
|
46
|
-
text: title
|
|
47
|
-
}
|
|
45
|
+
type: "mrkdwn",
|
|
46
|
+
text: title,
|
|
47
|
+
},
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
type:
|
|
50
|
+
type: "divider",
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
|
-
type:
|
|
53
|
+
type: "section",
|
|
54
54
|
text: {
|
|
55
|
-
type:
|
|
56
|
-
text: text
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
]
|
|
55
|
+
type: "plain_text",
|
|
56
|
+
text: text,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
60
|
}
|
|
61
61
|
end
|
|
62
62
|
|
|
@@ -66,7 +66,7 @@ module SlackWebhookLogger
|
|
|
66
66
|
msg
|
|
67
67
|
when ::Exception
|
|
68
68
|
"#{msg.message} (#{msg.class})\n" <<
|
|
69
|
-
|
|
69
|
+
(msg.backtrace || []).join("\n")
|
|
70
70
|
else
|
|
71
71
|
msg.inspect
|
|
72
72
|
end
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "active_support/core_ext/module/delegation"
|
|
4
4
|
|
|
5
5
|
module SlackWebhookLogger
|
|
6
6
|
class Logger < ::ActiveSupport::Logger
|
|
7
7
|
class << self
|
|
8
|
-
delegate :fatal,
|
|
9
|
-
|
|
8
|
+
delegate :fatal,
|
|
9
|
+
:error,
|
|
10
|
+
:warn,
|
|
11
|
+
:info,
|
|
12
|
+
:debug,
|
|
13
|
+
:add,
|
|
14
|
+
:log,
|
|
15
|
+
to: :instance
|
|
10
16
|
end
|
|
11
17
|
end
|
|
12
18
|
end
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "uri"
|
|
4
|
+
require "json"
|
|
5
|
+
require "httpx"
|
|
5
6
|
|
|
6
7
|
module SlackWebhookLogger
|
|
7
8
|
class RequestIO
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
class << self
|
|
10
|
+
def close
|
|
11
|
+
true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def write(hash)
|
|
15
|
+
return if hash.blank?
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
return if hash.blank?
|
|
17
|
+
return if SlackWebhookLogger.ignore_patterns.any? { |ignore_pattern| hash[:text].match(ignore_pattern) }
|
|
14
18
|
|
|
15
|
-
|
|
19
|
+
response = HTTPX.post(SlackWebhookLogger.webhook_uri.to_s, form: hash)
|
|
16
20
|
|
|
17
|
-
|
|
21
|
+
return if (200..299).cover?(response.status)
|
|
18
22
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
case response
|
|
24
|
+
when HTTPX::ErrorResponse
|
|
25
|
+
warn(response)
|
|
26
|
+
else
|
|
27
|
+
warn(response.body)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
22
30
|
end
|
|
23
31
|
end
|
|
24
32
|
end
|
data/lib/slack_webhook_logger.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "active_support/logger"
|
|
4
|
+
require "active_support/core_ext/module/attribute_accessors"
|
|
5
5
|
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
6
|
+
require "net/http"
|
|
7
|
+
require "net/https"
|
|
8
|
+
require "uri"
|
|
9
9
|
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
require
|
|
10
|
+
require "slack_webhook_logger/logger"
|
|
11
|
+
require "slack_webhook_logger/formatter"
|
|
12
|
+
require "slack_webhook_logger/request_io"
|
|
13
13
|
|
|
14
14
|
module SlackWebhookLogger
|
|
15
15
|
# Can be modified in Rails app
|
|
@@ -23,23 +23,24 @@ module SlackWebhookLogger
|
|
|
23
23
|
mattr_reader :logger
|
|
24
24
|
mattr_reader :https
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
class << self
|
|
27
|
+
# rubocop:disable Style/ClassVars
|
|
28
|
+
def setup
|
|
29
|
+
@@logger = SlackWebhookLogger::Logger.new(SlackWebhookLogger::RequestIO)
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
yield self
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
33
|
+
@@logger.formatter = @@formatter || SlackWebhookLogger::Formatter.new
|
|
34
|
+
@@logger.level = @@level || :warn
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
begin
|
|
37
|
+
@@webhook_uri = URI.parse(@@webhook_url)
|
|
38
|
+
rescue URI::InvalidURIError
|
|
39
|
+
raise ArgumentError, "Invalid URI for webhook_url"
|
|
40
|
+
end
|
|
39
41
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
@@ignore_patterns ||= []
|
|
43
|
+
end
|
|
44
|
+
# rubocop:enable Style/ClassVars
|
|
43
45
|
end
|
|
44
|
-
# rubocop:enable Style/ClassVars
|
|
45
46
|
end
|
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require_relative
|
|
3
|
+
require_relative "lib/slack_webhook_logger/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |spec|
|
|
6
|
-
spec.name =
|
|
6
|
+
spec.name = "slack_webhook_logger"
|
|
7
7
|
spec.version = SlackWebhookLogger::VERSION
|
|
8
|
-
spec.authors = [
|
|
9
|
-
spec.email = [
|
|
8
|
+
spec.authors = ["Garen J. Torikian"]
|
|
9
|
+
spec.email = ["gjtorikian@gmail.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary =
|
|
12
|
-
spec.homepage =
|
|
13
|
-
spec.license =
|
|
14
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
|
11
|
+
spec.summary = "A slim wrapper for posting to Rails logs to Slack"
|
|
12
|
+
spec.homepage = "https://github.com/gjtorikian/slack_webhook_logger"
|
|
13
|
+
spec.license = "MIT"
|
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new("~> 3.0")
|
|
15
15
|
|
|
16
|
-
spec.metadata[
|
|
17
|
-
spec.metadata[
|
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
|
18
18
|
|
|
19
19
|
# Specify which files should be added to the gem when it is released.
|
|
20
20
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
21
21
|
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
|
22
|
-
|
|
22
|
+
%x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
spec.require_paths = [
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
26
|
|
|
27
|
-
spec.add_dependency
|
|
28
|
-
spec.add_dependency
|
|
27
|
+
spec.add_dependency("activesupport", ">= 5.0", "< 8.0")
|
|
28
|
+
spec.add_dependency("httpx", "~> 0.20")
|
|
29
|
+
spec.add_dependency("railties", ">= 5.0", "< 8.0") # for the generators
|
|
29
30
|
spec.metadata = {
|
|
30
|
-
|
|
31
|
+
"rubygems_mfa_required" => "true",
|
|
31
32
|
}
|
|
32
33
|
end
|
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.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Garen J. Torikian
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -30,6 +30,20 @@ dependencies:
|
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
32
|
version: '8.0'
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: httpx
|
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0.20'
|
|
40
|
+
type: :runtime
|
|
41
|
+
prerelease: false
|
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '0.20'
|
|
33
47
|
- !ruby/object:Gem::Dependency
|
|
34
48
|
name: railties
|
|
35
49
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -50,7 +64,7 @@ dependencies:
|
|
|
50
64
|
- - "<"
|
|
51
65
|
- !ruby/object:Gem::Version
|
|
52
66
|
version: '8.0'
|
|
53
|
-
description:
|
|
67
|
+
description:
|
|
54
68
|
email:
|
|
55
69
|
- gjtorikian@gmail.com
|
|
56
70
|
executables: []
|
|
@@ -58,10 +72,16 @@ extensions: []
|
|
|
58
72
|
extra_rdoc_files: []
|
|
59
73
|
files:
|
|
60
74
|
- ".github/FUNDING.yml"
|
|
61
|
-
- ".github/
|
|
75
|
+
- ".github/dependabot.yml"
|
|
76
|
+
- ".github/workflows/automerge.yml"
|
|
62
77
|
- ".github/workflows/lint.yml"
|
|
78
|
+
- ".github/workflows/release.yml"
|
|
79
|
+
- ".github/workflows/test.yml"
|
|
63
80
|
- ".gitignore"
|
|
64
81
|
- ".rubocop.yml"
|
|
82
|
+
- ".ruby-version"
|
|
83
|
+
- ".vscode/settings.json"
|
|
84
|
+
- CHANGELOG.md
|
|
65
85
|
- CODE_OF_CONDUCT.md
|
|
66
86
|
- Gemfile
|
|
67
87
|
- Gemfile.lock
|
|
@@ -83,7 +103,7 @@ licenses:
|
|
|
83
103
|
- MIT
|
|
84
104
|
metadata:
|
|
85
105
|
rubygems_mfa_required: 'true'
|
|
86
|
-
post_install_message:
|
|
106
|
+
post_install_message:
|
|
87
107
|
rdoc_options: []
|
|
88
108
|
require_paths:
|
|
89
109
|
- lib
|
|
@@ -98,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
98
118
|
- !ruby/object:Gem::Version
|
|
99
119
|
version: '0'
|
|
100
120
|
requirements: []
|
|
101
|
-
rubygems_version: 3.
|
|
102
|
-
signing_key:
|
|
121
|
+
rubygems_version: 3.4.15
|
|
122
|
+
signing_key:
|
|
103
123
|
specification_version: 4
|
|
104
124
|
summary: A slim wrapper for posting to Rails logs to Slack
|
|
105
125
|
test_files: []
|
data/.github/workflows/ci.yml
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Ruby CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
|
|
6
|
-
jobs:
|
|
7
|
-
test:
|
|
8
|
-
runs-on: ubuntu-latest
|
|
9
|
-
|
|
10
|
-
strategy:
|
|
11
|
-
fail-fast: false
|
|
12
|
-
matrix:
|
|
13
|
-
ruby-version: [3.0.2]
|
|
14
|
-
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
|
|
18
|
-
- name: Set up Ruby ${{ matrix.ruby-version }}
|
|
19
|
-
uses: ruby/setup-ruby@v1
|
|
20
|
-
with:
|
|
21
|
-
ruby-version: ${{ matrix.ruby-version }}
|
|
22
|
-
bundler-cache: true
|
|
23
|
-
|
|
24
|
-
- name: Install dependencies
|
|
25
|
-
run: bundle install
|
|
26
|
-
|
|
27
|
-
- name: Run tests
|
|
28
|
-
run: bundle exec rake
|