memolog 0.3.5 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9dce059f72625002e6b813ad70cf427c5a3a59fb00cc614b6c9f80c8424bae8f
4
- data.tar.gz: 9e2fb92f533500da3d192c417b63578bfaa1984e76718e501393143e786796e5
3
+ metadata.gz: 2860b489711123341366bca28ab9916a82477faaa1fc83e198abb8cc321e5e45
4
+ data.tar.gz: a97dca8465a45b93374b1adb051920a1a2248cc3dfb6ea15c06af2f001c918dd
5
5
  SHA512:
6
- metadata.gz: 6d3dd9ff1c59a672936711f746fafb06921558108c3973ba174a8d3b08feb5ad239120d3422cf9a1fb53ff9621c6b10e82489b8da055774674821cef0e33eaaf
7
- data.tar.gz: 60a56a7a9bd93b7fb06383230b3874a41806cf422197675a148b31410b67265733fc89673613990e7e5adc279d9f5a0ac8ac134e8e2284b07503471ec7eb1e73
6
+ metadata.gz: 40c126dfd74fb20bf33da34014dacaa23e712960f29ebf0fc984bd1be8663e411caaab47d92e4f534ddaecdba96397c8701d94e1e7012573be93d378f3128d5f
7
+ data.tar.gz: e1a5555c422635bc703851da62f141dc47956ad70bffefc513f119de8da3987675934b576485dcdd82fbffa5a42f5a72d3a376efb4d184c94150a61255c5faaa
data/Gemfile CHANGED
@@ -4,10 +4,3 @@ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in memolog.gemspec
6
6
  gemspec
7
-
8
- gem "pry"
9
- gem "rails"
10
- gem "rake"
11
- gem "rspec"
12
- gem "rubocop-config-umbrellio"
13
- gem "sidekiq"
data/Gemfile.lock CHANGED
@@ -1,74 +1,75 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- memolog (0.3.5)
4
+ memolog (0.4.2)
5
+ json (~> 2)
5
6
  logger (~> 1.4.3)
6
7
  securerandom (~> 0.1.0)
7
8
 
8
9
  GEM
9
10
  remote: https://rubygems.org/
10
11
  specs:
11
- actioncable (7.0.1)
12
- actionpack (= 7.0.1)
13
- activesupport (= 7.0.1)
12
+ actioncable (7.0.2.2)
13
+ actionpack (= 7.0.2.2)
14
+ activesupport (= 7.0.2.2)
14
15
  nio4r (~> 2.0)
15
16
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.1)
17
- actionpack (= 7.0.1)
18
- activejob (= 7.0.1)
19
- activerecord (= 7.0.1)
20
- activestorage (= 7.0.1)
21
- activesupport (= 7.0.1)
17
+ actionmailbox (7.0.2.2)
18
+ actionpack (= 7.0.2.2)
19
+ activejob (= 7.0.2.2)
20
+ activerecord (= 7.0.2.2)
21
+ activestorage (= 7.0.2.2)
22
+ activesupport (= 7.0.2.2)
22
23
  mail (>= 2.7.1)
23
24
  net-imap
24
25
  net-pop
25
26
  net-smtp
26
- actionmailer (7.0.1)
27
- actionpack (= 7.0.1)
28
- actionview (= 7.0.1)
29
- activejob (= 7.0.1)
30
- activesupport (= 7.0.1)
27
+ actionmailer (7.0.2.2)
28
+ actionpack (= 7.0.2.2)
29
+ actionview (= 7.0.2.2)
30
+ activejob (= 7.0.2.2)
31
+ activesupport (= 7.0.2.2)
31
32
  mail (~> 2.5, >= 2.5.4)
32
33
  net-imap
33
34
  net-pop
34
35
  net-smtp
35
36
  rails-dom-testing (~> 2.0)
36
- actionpack (7.0.1)
37
- actionview (= 7.0.1)
38
- activesupport (= 7.0.1)
37
+ actionpack (7.0.2.2)
38
+ actionview (= 7.0.2.2)
39
+ activesupport (= 7.0.2.2)
39
40
  rack (~> 2.0, >= 2.2.0)
40
41
  rack-test (>= 0.6.3)
41
42
  rails-dom-testing (~> 2.0)
42
43
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.1)
44
- actionpack (= 7.0.1)
45
- activerecord (= 7.0.1)
46
- activestorage (= 7.0.1)
47
- activesupport (= 7.0.1)
44
+ actiontext (7.0.2.2)
45
+ actionpack (= 7.0.2.2)
46
+ activerecord (= 7.0.2.2)
47
+ activestorage (= 7.0.2.2)
48
+ activesupport (= 7.0.2.2)
48
49
  globalid (>= 0.6.0)
49
50
  nokogiri (>= 1.8.5)
50
- actionview (7.0.1)
51
- activesupport (= 7.0.1)
51
+ actionview (7.0.2.2)
52
+ activesupport (= 7.0.2.2)
52
53
  builder (~> 3.1)
53
54
  erubi (~> 1.4)
54
55
  rails-dom-testing (~> 2.0)
55
56
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.1)
57
- activesupport (= 7.0.1)
57
+ activejob (7.0.2.2)
58
+ activesupport (= 7.0.2.2)
58
59
  globalid (>= 0.3.6)
59
- activemodel (7.0.1)
60
- activesupport (= 7.0.1)
61
- activerecord (7.0.1)
62
- activemodel (= 7.0.1)
63
- activesupport (= 7.0.1)
64
- activestorage (7.0.1)
65
- actionpack (= 7.0.1)
66
- activejob (= 7.0.1)
67
- activerecord (= 7.0.1)
68
- activesupport (= 7.0.1)
60
+ activemodel (7.0.2.2)
61
+ activesupport (= 7.0.2.2)
62
+ activerecord (7.0.2.2)
63
+ activemodel (= 7.0.2.2)
64
+ activesupport (= 7.0.2.2)
65
+ activestorage (7.0.2.2)
66
+ actionpack (= 7.0.2.2)
67
+ activejob (= 7.0.2.2)
68
+ activerecord (= 7.0.2.2)
69
+ activesupport (= 7.0.2.2)
69
70
  marcel (~> 1.0)
70
71
  mini_mime (>= 1.1.0)
71
- activesupport (7.0.1)
72
+ activesupport (7.0.2.2)
72
73
  concurrent-ruby (~> 1.0, >= 1.0.2)
73
74
  i18n (>= 1.6, < 2)
74
75
  minitest (>= 5.1)
@@ -84,11 +85,12 @@ GEM
84
85
  erubi (1.10.0)
85
86
  globalid (1.0.0)
86
87
  activesupport (>= 5.0)
87
- i18n (1.9.1)
88
+ i18n (1.10.0)
88
89
  concurrent-ruby (~> 1.0)
89
90
  io-wait (0.2.1)
91
+ json (2.6.1)
90
92
  logger (1.4.4)
91
- loofah (2.13.0)
93
+ loofah (2.14.0)
92
94
  crass (~> 1.0.2)
93
95
  nokogiri (>= 1.5.9)
94
96
  mail (2.7.1)
@@ -113,12 +115,12 @@ GEM
113
115
  net-protocol
114
116
  timeout
115
117
  nio4r (2.5.8)
116
- nokogiri (1.13.1-x86_64-darwin)
118
+ nokogiri (1.13.3-x86_64-darwin)
117
119
  racc (~> 1.4)
118
- nokogiri (1.13.1-x86_64-linux)
120
+ nokogiri (1.13.3-x86_64-linux)
119
121
  racc (~> 1.4)
120
122
  parallel (1.21.0)
121
- parser (3.1.0.0)
123
+ parser (3.1.1.0)
122
124
  ast (~> 2.4.1)
123
125
  pry (0.14.1)
124
126
  coderay (~> 1.1)
@@ -127,51 +129,51 @@ GEM
127
129
  rack (2.2.3)
128
130
  rack-test (1.1.0)
129
131
  rack (>= 1.0, < 3)
130
- rails (7.0.1)
131
- actioncable (= 7.0.1)
132
- actionmailbox (= 7.0.1)
133
- actionmailer (= 7.0.1)
134
- actionpack (= 7.0.1)
135
- actiontext (= 7.0.1)
136
- actionview (= 7.0.1)
137
- activejob (= 7.0.1)
138
- activemodel (= 7.0.1)
139
- activerecord (= 7.0.1)
140
- activestorage (= 7.0.1)
141
- activesupport (= 7.0.1)
132
+ rails (7.0.2.2)
133
+ actioncable (= 7.0.2.2)
134
+ actionmailbox (= 7.0.2.2)
135
+ actionmailer (= 7.0.2.2)
136
+ actionpack (= 7.0.2.2)
137
+ actiontext (= 7.0.2.2)
138
+ actionview (= 7.0.2.2)
139
+ activejob (= 7.0.2.2)
140
+ activemodel (= 7.0.2.2)
141
+ activerecord (= 7.0.2.2)
142
+ activestorage (= 7.0.2.2)
143
+ activesupport (= 7.0.2.2)
142
144
  bundler (>= 1.15.0)
143
- railties (= 7.0.1)
145
+ railties (= 7.0.2.2)
144
146
  rails-dom-testing (2.0.3)
145
147
  activesupport (>= 4.2.0)
146
148
  nokogiri (>= 1.6)
147
149
  rails-html-sanitizer (1.4.2)
148
150
  loofah (~> 2.3)
149
- railties (7.0.1)
150
- actionpack (= 7.0.1)
151
- activesupport (= 7.0.1)
151
+ railties (7.0.2.2)
152
+ actionpack (= 7.0.2.2)
153
+ activesupport (= 7.0.2.2)
152
154
  method_source
153
155
  rake (>= 12.2)
154
156
  thor (~> 1.0)
155
157
  zeitwerk (~> 2.5)
156
158
  rainbow (3.1.1)
157
159
  rake (13.0.6)
158
- redis (4.5.1)
159
- regexp_parser (2.2.0)
160
+ redis (4.6.0)
161
+ regexp_parser (2.2.1)
160
162
  rexml (3.2.5)
161
- rspec (3.10.0)
162
- rspec-core (~> 3.10.0)
163
- rspec-expectations (~> 3.10.0)
164
- rspec-mocks (~> 3.10.0)
165
- rspec-core (3.10.2)
166
- rspec-support (~> 3.10.0)
167
- rspec-expectations (3.10.2)
163
+ rspec (3.11.0)
164
+ rspec-core (~> 3.11.0)
165
+ rspec-expectations (~> 3.11.0)
166
+ rspec-mocks (~> 3.11.0)
167
+ rspec-core (3.11.0)
168
+ rspec-support (~> 3.11.0)
169
+ rspec-expectations (3.11.0)
168
170
  diff-lcs (>= 1.2.0, < 2.0)
169
- rspec-support (~> 3.10.0)
170
- rspec-mocks (3.10.2)
171
+ rspec-support (~> 3.11.0)
172
+ rspec-mocks (3.11.0)
171
173
  diff-lcs (>= 1.2.0, < 2.0)
172
- rspec-support (~> 3.10.0)
173
- rspec-support (3.10.3)
174
- rubocop (1.25.0)
174
+ rspec-support (~> 3.11.0)
175
+ rspec-support (3.11.0)
176
+ rubocop (1.25.1)
175
177
  parallel (~> 1.10)
176
178
  parser (>= 3.1.0.0)
177
179
  rainbow (>= 2.2.2, < 4.0)
@@ -180,8 +182,8 @@ GEM
180
182
  rubocop-ast (>= 1.15.1, < 2.0)
181
183
  ruby-progressbar (~> 1.7)
182
184
  unicode-display_width (>= 1.4.0, < 3.0)
183
- rubocop-ast (1.15.1)
184
- parser (>= 3.0.1.1)
185
+ rubocop-ast (1.16.0)
186
+ parser (>= 3.1.1.0)
185
187
  rubocop-config-umbrellio (1.25.0.61)
186
188
  rubocop (~> 1.25.0)
187
189
  rubocop-performance (~> 1.13.0)
@@ -204,7 +206,7 @@ GEM
204
206
  rubocop (~> 1.0)
205
207
  ruby-progressbar (1.11.0)
206
208
  securerandom (0.1.1)
207
- sidekiq (6.4.0)
209
+ sidekiq (6.4.1)
208
210
  connection_pool (>= 2.2.2)
209
211
  rack (~> 2.0)
210
212
  redis (>= 4.2.0)
@@ -221,6 +223,7 @@ GEM
221
223
 
222
224
  PLATFORMS
223
225
  x86_64-darwin-20
226
+ x86_64-darwin-21
224
227
  x86_64-linux
225
228
 
226
229
  DEPENDENCIES
@@ -233,4 +236,4 @@ DEPENDENCIES
233
236
  sidekiq
234
237
 
235
238
  BUNDLED WITH
236
- 2.2.28
239
+ 2.3.7
data/README.md CHANGED
@@ -26,10 +26,10 @@ Use this example during application initialization process (this example impleme
26
26
  ```ruby
27
27
  Memolog.configure do |config|
28
28
  config.debug = false
29
- config.formatter = ::Memolog::Formatter.new
29
+ config.formatter = ::Logger::Formatter.new
30
30
  config.middlewares = %i[rails sidekiq]
31
+ config.log_json = false
31
32
  config.log_size_limit = 50_000
32
- config.uuid_callable = -> { SecureRandom.uuid }
33
33
  end
34
34
 
35
35
  Memolog.init_middlewares!
@@ -39,8 +39,8 @@ Available options are:
39
39
  - `debug` - set it to true if you need to leave Memolog.dump result outside `Memolog.run {}` block.
40
40
  - `formatter` - setup your own formatter.
41
41
  - `middlewares` - define here what you want to initialize in `#init_middlewares!` call.
42
+ - `log_json` - `#dump` will try to parse dump with `JSON.parse()`. Default is `false`
42
43
  - `log_size_limit` - max log length in `#dump`.
43
- - `uuid_callable` - Memolog add unique value to logs, here you can redefine uuid generation.
44
44
 
45
45
  If you want to apply Sentry monkey patch that call `Memolog.dump` before `Sentry.capture_exception`
46
46
  and `Sentry.capture_message` you can implement it via this code:
@@ -4,14 +4,14 @@ Memolog::Config = Struct.new(
4
4
  :debug,
5
5
  :formatter,
6
6
  :middlewares,
7
+ :parse_json,
7
8
  :log_size_limit,
8
- :uuid_callable,
9
9
  ) do
10
10
  def initialize
11
11
  self.debug = false
12
- self.formatter = ::Memolog::Formatter.new
12
+ self.formatter = ::Logger::Formatter.new
13
13
  self.middlewares = %i[rails sidekiq]
14
+ self.parse_json = false
14
15
  self.log_size_limit = 50_000
15
- self.uuid_callable = -> { SecureRandom.uuid }
16
16
  end
17
17
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Memolog
4
- VERSION = "0.3.5"
4
+ VERSION = "0.4.2"
5
5
  end
data/lib/memolog.rb CHANGED
@@ -3,10 +3,10 @@
3
3
  require "logger"
4
4
  require "securerandom"
5
5
  require "stringio"
6
+ require "json"
6
7
 
7
8
  require "memolog/version"
8
9
  require "memolog/config"
9
- require "memolog/formatter"
10
10
  require "memolog/init"
11
11
  require "memolog/logger_extension"
12
12
  require "memolog/rails_middleware"
@@ -30,11 +30,6 @@ module Memolog
30
30
 
31
31
  def extend_logger(other_logger)
32
32
  other_logger.extend(Memolog::LoggerExtension)
33
- other_logger.formatter = config.formatter
34
- end
35
-
36
- def uuid
37
- Thread.current[:memolog_uuid]
38
33
  end
39
34
 
40
35
  def logger
@@ -46,8 +41,6 @@ module Memolog
46
41
  end
47
42
 
48
43
  def run
49
- Thread.current[:memolog_uuid] = config.uuid_callable.call
50
-
51
44
  logdevs.push(StringIO.new)
52
45
  logger.instance_variable_set(:@logdev, logdevs.last)
53
46
 
@@ -62,6 +55,10 @@ module Memolog
62
55
  beginning = logdevs.last.string.length - config.log_size_limit
63
56
  beginning = 0 if beginning.negative?
64
57
 
65
- logdevs.last.string.slice(beginning, config.log_size_limit).presence
58
+ dump = logdevs.last.string.slice(beginning, config.log_size_limit).presence
59
+
60
+ dump && config.parse_json ? JSON.parse(dump) : dump
61
+ rescue JSON::ParserError
62
+ dump
66
63
  end
67
64
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memolog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-28 00:00:00.000000000 Z
11
+ date: 2022-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: logger
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,90 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: 0.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
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: rails
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: rake
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: rspec
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: rubocop-config-umbrellio
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'
41
139
  description: |2
42
140
  Memolog is an in-memory logger, which extend any other logger.
43
141
  Designed to work with Sentry.
@@ -61,7 +159,6 @@ files:
61
159
  - bin/setup
62
160
  - lib/memolog.rb
63
161
  - lib/memolog/config.rb
64
- - lib/memolog/formatter.rb
65
162
  - lib/memolog/init.rb
66
163
  - lib/memolog/logger_extension.rb
67
164
  - lib/memolog/rails_middleware.rb
@@ -90,7 +187,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
187
  - !ruby/object:Gem::Version
91
188
  version: '0'
92
189
  requirements: []
93
- rubygems_version: 3.2.15
190
+ rubygems_version: 3.3.3
94
191
  signing_key:
95
192
  specification_version: 4
96
193
  summary: In-memory logger for exceptions.
@@ -1,15 +0,0 @@
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