memolog 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.github/workflows/test.yml +36 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +248 -0
- data/LICENSE.txt +21 -0
- data/README.md +36 -0
- data/Rakefile +12 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/lib/memolog/config.rb +10 -0
- data/lib/memolog/extension.rb +13 -0
- data/lib/memolog/formatter.rb +15 -0
- data/lib/memolog/init.rb +17 -0
- data/lib/memolog/middleware.rb +11 -0
- data/lib/memolog/railtie.rb +7 -0
- data/lib/memolog/sentry_scope_extension.rb +8 -0
- data/lib/memolog/sentry_sidekiq_middleware.rb +13 -0
- data/lib/memolog/version.rb +5 -0
- data/lib/memolog.rb +63 -0
- metadata +196 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6bd5031cdc39d67fc6409bbe9d71028129040f13abd8f30445e5b0c4f090a005
|
4
|
+
data.tar.gz: 8d5e0699f794abd16aa2a2e11562085d538581c567af030bf7d3bd0e3e9bd304
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a894bc14c69acadbacd0dded2ea7ce4d04f2e607e19ecec70c570160976a0c79b8a9513b1024e305066bf4490e84ac8cc2927cf7a096e9df80cde82fe5f2fabe
|
7
|
+
data.tar.gz: 0415da3006d84de2b1804d3b2ac7e26d8f793617861a22c0a6eb71291c2d1071ff021b4859b9ee53d23b609bf66aaa4e7cef5e338d6fb9e6fb708fa874f5f197
|
@@ -0,0 +1,36 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
rubocop:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
steps:
|
14
|
+
- uses: actions/checkout@v2
|
15
|
+
- uses: ruby/setup-ruby@v1
|
16
|
+
with:
|
17
|
+
ruby-version: 3
|
18
|
+
bundler-cache: true
|
19
|
+
- name: Run rubocop
|
20
|
+
run: bundle exec rubocop
|
21
|
+
|
22
|
+
rspec:
|
23
|
+
runs-on: ubuntu-latest
|
24
|
+
|
25
|
+
strategy:
|
26
|
+
matrix:
|
27
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
28
|
+
|
29
|
+
steps:
|
30
|
+
- uses: actions/checkout@v2
|
31
|
+
- uses: ruby/setup-ruby@v1
|
32
|
+
with:
|
33
|
+
ruby-version: ${{ matrix.ruby }}
|
34
|
+
bundler-cache: true
|
35
|
+
- name: Run rspec
|
36
|
+
run: bundle exec rspec
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,248 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
memolog (0.1.0)
|
5
|
+
logger
|
6
|
+
securerandom
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actioncable (6.1.4.1)
|
12
|
+
actionpack (= 6.1.4.1)
|
13
|
+
activesupport (= 6.1.4.1)
|
14
|
+
nio4r (~> 2.0)
|
15
|
+
websocket-driver (>= 0.6.1)
|
16
|
+
actionmailbox (6.1.4.1)
|
17
|
+
actionpack (= 6.1.4.1)
|
18
|
+
activejob (= 6.1.4.1)
|
19
|
+
activerecord (= 6.1.4.1)
|
20
|
+
activestorage (= 6.1.4.1)
|
21
|
+
activesupport (= 6.1.4.1)
|
22
|
+
mail (>= 2.7.1)
|
23
|
+
actionmailer (6.1.4.1)
|
24
|
+
actionpack (= 6.1.4.1)
|
25
|
+
actionview (= 6.1.4.1)
|
26
|
+
activejob (= 6.1.4.1)
|
27
|
+
activesupport (= 6.1.4.1)
|
28
|
+
mail (~> 2.5, >= 2.5.4)
|
29
|
+
rails-dom-testing (~> 2.0)
|
30
|
+
actionpack (6.1.4.1)
|
31
|
+
actionview (= 6.1.4.1)
|
32
|
+
activesupport (= 6.1.4.1)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
34
|
+
rack-test (>= 0.6.3)
|
35
|
+
rails-dom-testing (~> 2.0)
|
36
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
37
|
+
actiontext (6.1.4.1)
|
38
|
+
actionpack (= 6.1.4.1)
|
39
|
+
activerecord (= 6.1.4.1)
|
40
|
+
activestorage (= 6.1.4.1)
|
41
|
+
activesupport (= 6.1.4.1)
|
42
|
+
nokogiri (>= 1.8.5)
|
43
|
+
actionview (6.1.4.1)
|
44
|
+
activesupport (= 6.1.4.1)
|
45
|
+
builder (~> 3.1)
|
46
|
+
erubi (~> 1.4)
|
47
|
+
rails-dom-testing (~> 2.0)
|
48
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
49
|
+
activejob (6.1.4.1)
|
50
|
+
activesupport (= 6.1.4.1)
|
51
|
+
globalid (>= 0.3.6)
|
52
|
+
activemodel (6.1.4.1)
|
53
|
+
activesupport (= 6.1.4.1)
|
54
|
+
activerecord (6.1.4.1)
|
55
|
+
activemodel (= 6.1.4.1)
|
56
|
+
activesupport (= 6.1.4.1)
|
57
|
+
activestorage (6.1.4.1)
|
58
|
+
actionpack (= 6.1.4.1)
|
59
|
+
activejob (= 6.1.4.1)
|
60
|
+
activerecord (= 6.1.4.1)
|
61
|
+
activesupport (= 6.1.4.1)
|
62
|
+
marcel (~> 1.0.0)
|
63
|
+
mini_mime (>= 1.1.0)
|
64
|
+
activesupport (6.1.4.1)
|
65
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
70
|
+
ast (2.4.2)
|
71
|
+
builder (3.2.4)
|
72
|
+
coderay (1.1.3)
|
73
|
+
concurrent-ruby (1.1.9)
|
74
|
+
connection_pool (2.2.5)
|
75
|
+
crass (1.0.6)
|
76
|
+
diff-lcs (1.4.4)
|
77
|
+
erubi (1.10.0)
|
78
|
+
faraday (1.8.0)
|
79
|
+
faraday-em_http (~> 1.0)
|
80
|
+
faraday-em_synchrony (~> 1.0)
|
81
|
+
faraday-excon (~> 1.1)
|
82
|
+
faraday-httpclient (~> 1.0.1)
|
83
|
+
faraday-net_http (~> 1.0)
|
84
|
+
faraday-net_http_persistent (~> 1.1)
|
85
|
+
faraday-patron (~> 1.0)
|
86
|
+
faraday-rack (~> 1.0)
|
87
|
+
multipart-post (>= 1.2, < 3)
|
88
|
+
ruby2_keywords (>= 0.0.4)
|
89
|
+
faraday-em_http (1.0.0)
|
90
|
+
faraday-em_synchrony (1.0.0)
|
91
|
+
faraday-excon (1.1.0)
|
92
|
+
faraday-httpclient (1.0.1)
|
93
|
+
faraday-net_http (1.0.1)
|
94
|
+
faraday-net_http_persistent (1.2.0)
|
95
|
+
faraday-patron (1.0.0)
|
96
|
+
faraday-rack (1.0.0)
|
97
|
+
globalid (0.5.2)
|
98
|
+
activesupport (>= 5.0)
|
99
|
+
i18n (1.8.10)
|
100
|
+
concurrent-ruby (~> 1.0)
|
101
|
+
logger (1.4.3)
|
102
|
+
loofah (2.12.0)
|
103
|
+
crass (~> 1.0.2)
|
104
|
+
nokogiri (>= 1.5.9)
|
105
|
+
mail (2.7.1)
|
106
|
+
mini_mime (>= 0.1.1)
|
107
|
+
marcel (1.0.2)
|
108
|
+
method_source (1.0.0)
|
109
|
+
mini_mime (1.1.1)
|
110
|
+
minitest (5.14.4)
|
111
|
+
multipart-post (2.1.1)
|
112
|
+
nio4r (2.5.8)
|
113
|
+
nokogiri (1.12.4-x86_64-darwin)
|
114
|
+
racc (~> 1.4)
|
115
|
+
nokogiri (1.12.4-x86_64-linux)
|
116
|
+
racc (~> 1.4)
|
117
|
+
parallel (1.21.0)
|
118
|
+
parser (3.0.2.0)
|
119
|
+
ast (~> 2.4.1)
|
120
|
+
pry (0.14.1)
|
121
|
+
coderay (~> 1.1)
|
122
|
+
method_source (~> 1.0)
|
123
|
+
racc (1.5.2)
|
124
|
+
rack (2.2.3)
|
125
|
+
rack-test (1.1.0)
|
126
|
+
rack (>= 1.0, < 3)
|
127
|
+
rails (6.1.4.1)
|
128
|
+
actioncable (= 6.1.4.1)
|
129
|
+
actionmailbox (= 6.1.4.1)
|
130
|
+
actionmailer (= 6.1.4.1)
|
131
|
+
actionpack (= 6.1.4.1)
|
132
|
+
actiontext (= 6.1.4.1)
|
133
|
+
actionview (= 6.1.4.1)
|
134
|
+
activejob (= 6.1.4.1)
|
135
|
+
activemodel (= 6.1.4.1)
|
136
|
+
activerecord (= 6.1.4.1)
|
137
|
+
activestorage (= 6.1.4.1)
|
138
|
+
activesupport (= 6.1.4.1)
|
139
|
+
bundler (>= 1.15.0)
|
140
|
+
railties (= 6.1.4.1)
|
141
|
+
sprockets-rails (>= 2.0.0)
|
142
|
+
rails-dom-testing (2.0.3)
|
143
|
+
activesupport (>= 4.2.0)
|
144
|
+
nokogiri (>= 1.6)
|
145
|
+
rails-html-sanitizer (1.4.2)
|
146
|
+
loofah (~> 2.3)
|
147
|
+
railties (6.1.4.1)
|
148
|
+
actionpack (= 6.1.4.1)
|
149
|
+
activesupport (= 6.1.4.1)
|
150
|
+
method_source
|
151
|
+
rake (>= 0.13)
|
152
|
+
thor (~> 1.0)
|
153
|
+
rainbow (3.0.0)
|
154
|
+
rake (13.0.6)
|
155
|
+
redis (4.4.0)
|
156
|
+
regexp_parser (2.1.1)
|
157
|
+
rexml (3.2.5)
|
158
|
+
rspec (3.10.0)
|
159
|
+
rspec-core (~> 3.10.0)
|
160
|
+
rspec-expectations (~> 3.10.0)
|
161
|
+
rspec-mocks (~> 3.10.0)
|
162
|
+
rspec-core (3.10.1)
|
163
|
+
rspec-support (~> 3.10.0)
|
164
|
+
rspec-expectations (3.10.1)
|
165
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
166
|
+
rspec-support (~> 3.10.0)
|
167
|
+
rspec-mocks (3.10.2)
|
168
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
169
|
+
rspec-support (~> 3.10.0)
|
170
|
+
rspec-support (3.10.2)
|
171
|
+
rubocop (1.17.0)
|
172
|
+
parallel (~> 1.10)
|
173
|
+
parser (>= 3.0.0.0)
|
174
|
+
rainbow (>= 2.2.2, < 4.0)
|
175
|
+
regexp_parser (>= 1.8, < 3.0)
|
176
|
+
rexml
|
177
|
+
rubocop-ast (>= 1.7.0, < 2.0)
|
178
|
+
ruby-progressbar (~> 1.7)
|
179
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
180
|
+
rubocop-ast (1.11.0)
|
181
|
+
parser (>= 3.0.1.1)
|
182
|
+
rubocop-config-umbrellio (1.17.0.53)
|
183
|
+
rubocop (= 1.17.0)
|
184
|
+
rubocop-performance (= 1.10.0)
|
185
|
+
rubocop-rails (= 2.9.1)
|
186
|
+
rubocop-rake (= 0.5.1)
|
187
|
+
rubocop-rspec (= 2.2.0)
|
188
|
+
rubocop-sequel (= 0.2.0)
|
189
|
+
rubocop-performance (1.10.0)
|
190
|
+
rubocop (>= 0.90.0, < 2.0)
|
191
|
+
rubocop-ast (>= 0.4.0)
|
192
|
+
rubocop-rails (2.9.1)
|
193
|
+
activesupport (>= 4.2.0)
|
194
|
+
rack (>= 1.1)
|
195
|
+
rubocop (>= 0.90.0, < 2.0)
|
196
|
+
rubocop-rake (0.5.1)
|
197
|
+
rubocop
|
198
|
+
rubocop-rspec (2.2.0)
|
199
|
+
rubocop (~> 1.0)
|
200
|
+
rubocop-ast (>= 1.1.0)
|
201
|
+
rubocop-sequel (0.2.0)
|
202
|
+
rubocop (~> 1.0)
|
203
|
+
ruby-progressbar (1.11.0)
|
204
|
+
ruby2_keywords (0.0.5)
|
205
|
+
securerandom (0.1.0)
|
206
|
+
sentry-ruby (4.7.3)
|
207
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
208
|
+
faraday (>= 1.0)
|
209
|
+
sentry-ruby-core (= 4.7.3)
|
210
|
+
sentry-ruby-core (4.7.3)
|
211
|
+
concurrent-ruby
|
212
|
+
faraday
|
213
|
+
sidekiq (6.2.2)
|
214
|
+
connection_pool (>= 2.2.2)
|
215
|
+
rack (~> 2.0)
|
216
|
+
redis (>= 4.2.0)
|
217
|
+
sprockets (4.0.2)
|
218
|
+
concurrent-ruby (~> 1.0)
|
219
|
+
rack (> 1, < 3)
|
220
|
+
sprockets-rails (3.2.2)
|
221
|
+
actionpack (>= 4.0)
|
222
|
+
activesupport (>= 4.0)
|
223
|
+
sprockets (>= 3.0.0)
|
224
|
+
thor (1.1.0)
|
225
|
+
tzinfo (2.0.4)
|
226
|
+
concurrent-ruby (~> 1.0)
|
227
|
+
unicode-display_width (2.1.0)
|
228
|
+
websocket-driver (0.7.5)
|
229
|
+
websocket-extensions (>= 0.1.0)
|
230
|
+
websocket-extensions (0.1.5)
|
231
|
+
zeitwerk (2.4.2)
|
232
|
+
|
233
|
+
PLATFORMS
|
234
|
+
x86_64-darwin-20
|
235
|
+
x86_64-linux
|
236
|
+
|
237
|
+
DEPENDENCIES
|
238
|
+
memolog!
|
239
|
+
pry
|
240
|
+
rails
|
241
|
+
rake
|
242
|
+
rspec
|
243
|
+
rubocop-config-umbrellio
|
244
|
+
sentry-ruby
|
245
|
+
sidekiq
|
246
|
+
|
247
|
+
BUNDLED WITH
|
248
|
+
2.2.28
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Stepan Kirushkin
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# Memolog
|
2
|
+
|
3
|
+
Memolog is an in-memory logger, which extend any other logger.
|
4
|
+
Designed to work with [Sentry](https://github.com/getsentry/sentry-ruby).
|
5
|
+
It adds `memolog` extra section to Sentry errors.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "memolog"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install memolog
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Memolog has init code for Rails (Middleware), Sentry (Extension) and Sidekiq (Middleware).
|
26
|
+
It implement all hacks on the load process.
|
27
|
+
Also you can add `Memolog.run {}` around logs you want to collect and release it with `Memolog.dump`
|
28
|
+
inside this block.
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/skirushkin/memolog.
|
33
|
+
|
34
|
+
## License
|
35
|
+
|
36
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "memolog"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
Memolog::Config = Struct.new(:formatter, :uuid_callable, :sentry_key, :log_size_limit) do
|
4
|
+
def initialize
|
5
|
+
self.formatter = ::Memolog::Formatter.new
|
6
|
+
self.uuid_callable = -> { SecureRandom.uuid }
|
7
|
+
self.sentry_key = :memolog
|
8
|
+
self.log_size_limit = 50_000
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Memolog::Formatter < Logger::Formatter
|
4
|
+
def call(severity, time, _progname, msg)
|
5
|
+
format(
|
6
|
+
Format,
|
7
|
+
severity[0..0],
|
8
|
+
format_datetime(time),
|
9
|
+
$PID,
|
10
|
+
severity,
|
11
|
+
Memolog.uuid,
|
12
|
+
msg2str(msg),
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
data/lib/memolog/init.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if defined?(Rails::Railtie)
|
4
|
+
require "memolog/railtie"
|
5
|
+
end
|
6
|
+
|
7
|
+
if defined?(Sentry::Scope)
|
8
|
+
Sentry::Scope.prepend(Memolog::SentryScopeExtension)
|
9
|
+
end
|
10
|
+
|
11
|
+
if defined?(Sidekiq)
|
12
|
+
Sidekiq.configure_server do |config|
|
13
|
+
config.server_middleware do |chain|
|
14
|
+
chain.prepend(Memolog::SentrySidekiqMiddleware)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Memolog::SentrySidekiqMiddleware
|
4
|
+
def call(*)
|
5
|
+
Memolog.run do
|
6
|
+
yield
|
7
|
+
rescue => error
|
8
|
+
memolog_dump = Memolog.dump
|
9
|
+
Sentry.set_extras(Memolog.config.sentry_key => memolog_dump) if memolog_dump
|
10
|
+
raise error
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/memolog.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "logger"
|
4
|
+
require "securerandom"
|
5
|
+
|
6
|
+
module Memolog
|
7
|
+
extend self
|
8
|
+
|
9
|
+
autoload :VERSION, "memolog/version"
|
10
|
+
autoload :Config, "memolog/config"
|
11
|
+
autoload :Extension, "memolog/extension"
|
12
|
+
autoload :Formatter, "memolog/formatter"
|
13
|
+
autoload :Middleware, "memolog/middleware"
|
14
|
+
autoload :SentryScopeExtension, "memolog/sentry_scope_extension"
|
15
|
+
autoload :SentrySidekiqMiddleware, "memolog/sentry_sidekiq_middleware"
|
16
|
+
|
17
|
+
attr_accessor :debug, :logdevs
|
18
|
+
|
19
|
+
self.debug = false
|
20
|
+
self.logdevs = []
|
21
|
+
|
22
|
+
def configure
|
23
|
+
@config ||= Memolog::Config.new
|
24
|
+
yield(@config) if block_given?
|
25
|
+
@config
|
26
|
+
end
|
27
|
+
alias config configure
|
28
|
+
|
29
|
+
def extend_logger(other_logger)
|
30
|
+
other_logger.extend(Memolog::Extension)
|
31
|
+
other_logger.formatter = config.formatter
|
32
|
+
end
|
33
|
+
|
34
|
+
def logger
|
35
|
+
Thread.current[:memolog_logger] ||= Logger.new(nil, formatter: config.formatter)
|
36
|
+
end
|
37
|
+
|
38
|
+
def uuid
|
39
|
+
Thread.current[:memolog_uuid]
|
40
|
+
end
|
41
|
+
|
42
|
+
def run
|
43
|
+
Thread.current[:memolog_uuid] = Memolog.config.uuid_callable.call
|
44
|
+
|
45
|
+
logdevs.push(StringIO.new)
|
46
|
+
logger.instance_variable_set(:@logdev, logdevs.last)
|
47
|
+
|
48
|
+
yield
|
49
|
+
ensure
|
50
|
+
logdevs.pop unless debug
|
51
|
+
end
|
52
|
+
|
53
|
+
def dump
|
54
|
+
return if logdevs.empty?
|
55
|
+
|
56
|
+
beginning = logdevs.last.string.length - config.log_size_limit
|
57
|
+
beginning = 0 if beginning.negative?
|
58
|
+
|
59
|
+
logdevs.last.string.slice(beginning, config.log_size_limit)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
require "memolog/init"
|
metadata
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: memolog
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stepan Kirushkin
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-09-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: logger
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: securerandom
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-config-umbrellio
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: sentry-ruby
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: sidekiq
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: |2
|
140
|
+
Memolog is an in-memory logger, which extend any other logger.
|
141
|
+
Designed to work with Sentry.
|
142
|
+
It adds `memolog` extra section to Sentry errors.
|
143
|
+
email:
|
144
|
+
- stepan.kirushkin@gmail.com
|
145
|
+
executables: []
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- ".github/workflows/test.yml"
|
150
|
+
- ".gitignore"
|
151
|
+
- ".rubocop.yml"
|
152
|
+
- CHANGELOG.md
|
153
|
+
- Gemfile
|
154
|
+
- Gemfile.lock
|
155
|
+
- LICENSE.txt
|
156
|
+
- README.md
|
157
|
+
- Rakefile
|
158
|
+
- bin/console
|
159
|
+
- bin/setup
|
160
|
+
- lib/memolog.rb
|
161
|
+
- lib/memolog/config.rb
|
162
|
+
- lib/memolog/extension.rb
|
163
|
+
- lib/memolog/formatter.rb
|
164
|
+
- lib/memolog/init.rb
|
165
|
+
- lib/memolog/middleware.rb
|
166
|
+
- lib/memolog/railtie.rb
|
167
|
+
- lib/memolog/sentry_scope_extension.rb
|
168
|
+
- lib/memolog/sentry_sidekiq_middleware.rb
|
169
|
+
- lib/memolog/version.rb
|
170
|
+
homepage: https://github.com/skirushkin/memolog
|
171
|
+
licenses:
|
172
|
+
- MIT
|
173
|
+
metadata:
|
174
|
+
homepage_uri: https://github.com/skirushkin/memolog
|
175
|
+
source_code_uri: https://github.com/skirushkin/memolog
|
176
|
+
changelog_uri: https://github.com/skirushkin/memolog
|
177
|
+
post_install_message:
|
178
|
+
rdoc_options: []
|
179
|
+
require_paths:
|
180
|
+
- lib
|
181
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
version: 2.5.0
|
186
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - ">="
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '0'
|
191
|
+
requirements: []
|
192
|
+
rubygems_version: 3.2.15
|
193
|
+
signing_key:
|
194
|
+
specification_version: 4
|
195
|
+
summary: In-memory logger for exceptions.
|
196
|
+
test_files: []
|