memolog 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -2
- data/Gemfile.lock +1 -34
- data/README.md +7 -10
- data/lib/memolog/config.rb +1 -3
- data/lib/memolog/init.rb +4 -12
- data/lib/memolog/sentry_extension.rb +5 -8
- data/lib/memolog/version.rb +1 -1
- data/lib/memolog.rb +5 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97630c7e390e26c97872776f9c6b142fcb18cafaf05ceb937a8ee4a10537212c
|
4
|
+
data.tar.gz: 568faf40b03bc8488d651b7e09eda247f5f22e399d583d97b671868618b91e4c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb3b455425fa4e68c68620248e1cf3493e1888e7023e62cb1179b31b1a316def07c0b918ae1fa4ba3b3ff6b23c339a9f481a340fcd784a712405622ad87a77b1
|
7
|
+
data.tar.gz: 8cde0d72453487d056a4e507a06943bc21d2a5c5d52a8c6298b85bdc81375c189fd39904be27fb5304757cbba70493650b9a14ec4f0482846ae7ae587fe11572
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
memolog (0.3.
|
4
|
+
memolog (0.3.2)
|
5
5
|
logger (~> 1.4.3)
|
6
6
|
securerandom (~> 0.1.0)
|
7
7
|
|
@@ -75,25 +75,6 @@ GEM
|
|
75
75
|
crass (1.0.6)
|
76
76
|
diff-lcs (1.4.4)
|
77
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
78
|
globalid (0.5.2)
|
98
79
|
activesupport (>= 5.0)
|
99
80
|
i18n (1.8.10)
|
@@ -108,7 +89,6 @@ GEM
|
|
108
89
|
method_source (1.0.0)
|
109
90
|
mini_mime (1.1.1)
|
110
91
|
minitest (5.14.4)
|
111
|
-
multipart-post (2.1.1)
|
112
92
|
nio4r (2.5.8)
|
113
93
|
nokogiri (1.12.5-x86_64-darwin)
|
114
94
|
racc (~> 1.4)
|
@@ -201,18 +181,7 @@ GEM
|
|
201
181
|
rubocop-sequel (0.2.0)
|
202
182
|
rubocop (~> 1.0)
|
203
183
|
ruby-progressbar (1.11.0)
|
204
|
-
ruby2_keywords (0.0.5)
|
205
184
|
securerandom (0.1.1)
|
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
|
-
sentry-sidekiq (4.7.3)
|
214
|
-
sentry-ruby-core (~> 4.7.0)
|
215
|
-
sidekiq (>= 3.0)
|
216
185
|
sidekiq (6.2.2)
|
217
186
|
connection_pool (>= 2.2.2)
|
218
187
|
rack (~> 2.0)
|
@@ -244,8 +213,6 @@ DEPENDENCIES
|
|
244
213
|
rake
|
245
214
|
rspec
|
246
215
|
rubocop-config-umbrellio
|
247
|
-
sentry-ruby
|
248
|
-
sentry-sidekiq
|
249
216
|
sidekiq
|
250
217
|
|
251
218
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# Memolog
|
2
2
|
|
3
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.
|
4
|
+
Designed to work with [Sentry](https://github.com/getsentry/sentry-ruby) but it's not necessary.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -28,9 +27,8 @@ Use this example during application initialization process (this example impleme
|
|
28
27
|
Memolog.configure do |config|
|
29
28
|
config.debug = false
|
30
29
|
config.formatter = ::Memolog::Formatter.new
|
31
|
-
config.initializers = %i[rails
|
30
|
+
config.initializers = %i[rails sidekiq]
|
32
31
|
config.log_size_limit = 50_000
|
33
|
-
config.sentry_key = :memolog
|
34
32
|
config.uuid_callable = -> { SecureRandom.uuid }
|
35
33
|
end
|
36
34
|
|
@@ -41,18 +39,17 @@ Available options are:
|
|
41
39
|
- `debug` - set it to true if you need to leave Memolog.dump result outside `Memolog.run {}` block.
|
42
40
|
- `formatter` - setup your own formatter.
|
43
41
|
- `initializers` - define here what you want to initialize in `#init!` call.
|
44
|
-
- `log_size_limit` - max log length in
|
45
|
-
- `sentry_key` - key name in Sentry extra object.
|
42
|
+
- `log_size_limit` - max log length in `#dump`.
|
46
43
|
- `uuid_callable` - Memolog add unique value to logs, here you can redefine uuid generation.
|
47
44
|
|
48
45
|
## Usage
|
49
46
|
|
50
47
|
Please call `Memolog.extend_logger(Rails.logger)` or any other logger you want to collect.
|
51
|
-
After that when error occured you can
|
52
|
-
|
53
|
-
server or log collection system.
|
48
|
+
After that when error occured you can call `Memolog.dump` in your code and get log from
|
49
|
+
`Rails.logger` so you can collect it to another place (Sentry or etc). Also there will be unique
|
50
|
+
identifier to find logs behaviour on your server or log collection system.
|
54
51
|
|
55
|
-
Memolog has init code for Rails (Middleware)
|
52
|
+
Memolog has init code for Rails (Middleware) and Sidekiq (Middleware).
|
56
53
|
It implement all hacks on the `Memolog.init!` call.
|
57
54
|
Also you can add `Memolog.run {}` around logs you want to collect and release it with `Memolog.dump`
|
58
55
|
inside this block.
|
data/lib/memolog/config.rb
CHANGED
@@ -5,15 +5,13 @@ Memolog::Config = Struct.new(
|
|
5
5
|
:formatter,
|
6
6
|
:initializers,
|
7
7
|
:log_size_limit,
|
8
|
-
:sentry_key,
|
9
8
|
:uuid_callable,
|
10
9
|
) do
|
11
10
|
def initialize
|
12
11
|
self.debug = false
|
13
12
|
self.formatter = ::Memolog::Formatter.new
|
14
|
-
self.initializers = %i[rails
|
13
|
+
self.initializers = %i[rails sidekiq]
|
15
14
|
self.log_size_limit = 50_000
|
16
|
-
self.sentry_key = :memolog
|
17
15
|
self.uuid_callable = -> { SecureRandom.uuid }
|
18
16
|
end
|
19
17
|
end
|
data/lib/memolog/init.rb
CHANGED
@@ -2,14 +2,13 @@
|
|
2
2
|
|
3
3
|
class Memolog::Init
|
4
4
|
def call
|
5
|
-
|
6
|
-
|
7
|
-
init_sidekiq!
|
5
|
+
init_rails_middleware!
|
6
|
+
init_sidekiq_middleware!
|
8
7
|
end
|
9
8
|
|
10
9
|
private
|
11
10
|
|
12
|
-
def
|
11
|
+
def init_rails_middleware!
|
13
12
|
return unless Memolog.config.initializers.include?(:rails)
|
14
13
|
return unless Object.const_defined?("Rails")
|
15
14
|
return if Object.const_defined?("Sidekiq") && Sidekiq.server?
|
@@ -17,14 +16,7 @@ class Memolog::Init
|
|
17
16
|
Rails.application.middleware.insert_before(0, Memolog::RailsMiddleware)
|
18
17
|
end
|
19
18
|
|
20
|
-
def
|
21
|
-
return unless Memolog.config.initializers.include?(:sentry)
|
22
|
-
return unless Object.const_defined?("Sentry")
|
23
|
-
|
24
|
-
Sentry.prepend(Memolog::SentryExtension)
|
25
|
-
end
|
26
|
-
|
27
|
-
def init_sidekiq!
|
19
|
+
def init_sidekiq_middleware!
|
28
20
|
return unless Memolog.config.initializers.include?(:sidekiq)
|
29
21
|
return unless Object.const_defined?("Sidekiq")
|
30
22
|
|
@@ -7,21 +7,18 @@ module Memolog::SentryExtension
|
|
7
7
|
|
8
8
|
module ClassMethods
|
9
9
|
def capture_exception(exception, **options, &block)
|
10
|
-
|
10
|
+
set_extras_memolog!
|
11
11
|
super
|
12
12
|
end
|
13
13
|
|
14
14
|
def capture_message(message, **options, &block)
|
15
|
-
|
15
|
+
set_extras_memolog!
|
16
16
|
super
|
17
17
|
end
|
18
18
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
scope = get_current_scope
|
24
|
-
scope.set_extras(Memolog.config.sentry_key => dump) if scope # rubocop:disable Style/SafeNavigation
|
19
|
+
def set_extras_memolog!
|
20
|
+
return unless get_current_scope
|
21
|
+
set_extras(Memolog.config.sentry_key => Memolog.dump)
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
data/lib/memolog/version.rb
CHANGED
data/lib/memolog.rb
CHANGED
@@ -16,10 +16,9 @@ require "memolog/sidekiq_middleware"
|
|
16
16
|
module Memolog
|
17
17
|
extend self
|
18
18
|
|
19
|
-
attr_accessor :config
|
19
|
+
attr_accessor :config
|
20
20
|
|
21
21
|
@config = Memolog::Config.new
|
22
|
-
@logdevs = []
|
23
22
|
|
24
23
|
def configure
|
25
24
|
yield(config) if block_given?
|
@@ -42,6 +41,10 @@ module Memolog
|
|
42
41
|
Thread.current[:memolog_logger] ||= Logger.new(nil, formatter: config.formatter)
|
43
42
|
end
|
44
43
|
|
44
|
+
def logdevs
|
45
|
+
Thread.current[:memolog_logdevs] ||= []
|
46
|
+
end
|
47
|
+
|
45
48
|
def run
|
46
49
|
Thread.current[:memolog_uuid] = config.uuid_callable.call
|
47
50
|
|