memolog 0.3.1 → 0.3.2

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
  SHA256:
3
- metadata.gz: a4c3d9289bf4c0378b3050613589595dbf2c1d1e5a25a0fa9f0c3d2302a2963e
4
- data.tar.gz: 0b56db61731b0e1bd1c293216cf0a0fab009ea8eb70be2b85601a27b70cdf284
3
+ metadata.gz: 97630c7e390e26c97872776f9c6b142fcb18cafaf05ceb937a8ee4a10537212c
4
+ data.tar.gz: 568faf40b03bc8488d651b7e09eda247f5f22e399d583d97b671868618b91e4c
5
5
  SHA512:
6
- metadata.gz: 6a25437819058d1330f195a7dbbeea54d728face25790bc83c6fcba84500e18b459a8d50730c79e598b86c4c7a0f953d5ab804c2d71bb38c3d2f898a08097761
7
- data.tar.gz: 0b90e159e40b2a0e4a7fb0c0aa84e96a8de0fb3b4538346e5614f894f001574c7c0157963273d50081aa36fc732085f46bd97afa9991d42085235e393a3d5e93
6
+ metadata.gz: fb3b455425fa4e68c68620248e1cf3493e1888e7023e62cb1179b31b1a316def07c0b918ae1fa4ba3b3ff6b23c339a9f481a340fcd784a712405622ad87a77b1
7
+ data.tar.gz: 8cde0d72453487d056a4e507a06943bc21d2a5c5d52a8c6298b85bdc81375c189fd39904be27fb5304757cbba70493650b9a14ec4f0482846ae7ae587fe11572
data/Gemfile CHANGED
@@ -10,6 +10,4 @@ gem "rails"
10
10
  gem "rake"
11
11
  gem "rspec"
12
12
  gem "rubocop-config-umbrellio"
13
- gem "sentry-ruby"
14
- gem "sentry-sidekiq"
15
13
  gem "sidekiq"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- memolog (0.3.1)
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 sentry sidekiq]
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 Sentry event.
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 check your Sentry report and see `memolog` section with all
52
- logs collected before error. Also there will be unique identifier to find logs behaviour on your
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), Sentry (Extension) and Sidekiq (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.
@@ -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 sentry sidekiq]
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
- init_rails!
6
- init_sentry!
7
- init_sidekiq!
5
+ init_rails_middleware!
6
+ init_sidekiq_middleware!
8
7
  end
9
8
 
10
9
  private
11
10
 
12
- def init_rails!
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 init_sentry!
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
- add_memolog_to_current_scope!
10
+ set_extras_memolog!
11
11
  super
12
12
  end
13
13
 
14
14
  def capture_message(message, **options, &block)
15
- add_memolog_to_current_scope!
15
+ set_extras_memolog!
16
16
  super
17
17
  end
18
18
 
19
- def add_memolog_to_current_scope!
20
- dump = Memolog.dump
21
- return unless dump
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memolog
4
- VERSION = "0.3.1"
4
+ VERSION = "0.3.2"
5
5
  end
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, :logdevs
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memolog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin