loga 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +1 -0
- data/.codeclimate.yml +3 -1
- data/.gitignore +2 -0
- data/.rubocop.yml +29 -2
- data/Appraisals +4 -0
- data/CHANGELOG.md +4 -0
- data/Guardfile +14 -0
- data/README.md +4 -0
- data/gemfiles/sidekiq51.gemfile +11 -0
- data/lib/loga.rb +4 -3
- data/lib/loga/ext/core/tempfile.rb +1 -1
- data/lib/loga/formatters/simple_formatter.rb +1 -3
- data/lib/loga/rack/request.rb +2 -2
- data/lib/loga/sidekiq.rb +16 -0
- data/lib/loga/sidekiq/job_logger.rb +62 -0
- data/lib/loga/utilities.rb +1 -1
- data/lib/loga/version.rb +1 -1
- data/loga.gemspec +4 -2
- data/spec/fixtures/rails32.rb +1 -0
- data/spec/integration/rails/railtie_spec.rb +9 -8
- data/spec/integration/rails/request_spec.rb +2 -2
- data/spec/integration/sidekiq_spec.rb +131 -0
- data/spec/integration/sinatra_spec.rb +17 -16
- data/spec/loga/sidekiq/job_logger_spec.rb +115 -0
- data/spec/loga/sidekiq_spec.rb +53 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/support/helpers.rb +8 -1
- data/spec/support/request_spec.rb +4 -4
- data/spec/support/timecop_shared.rb +1 -0
- data/spec/unit/loga/configuration_spec.rb +7 -4
- data/spec/unit/loga/event_spec.rb +2 -2
- data/spec/unit/loga/formatters/gelf_formatter_spec.rb +7 -5
- data/spec/unit/loga/formatters/simple_formatter_spec.rb +3 -0
- data/spec/unit/loga/log_subscribers/action_mailer_spec.rb +14 -13
- data/spec/unit/loga/parameter_filter_spec.rb +1 -1
- data/spec/unit/loga/rack/logger_spec.rb +10 -6
- data/spec/unit/loga/rack/request_spec.rb +4 -3
- data/spec/unit/loga/utilities_spec.rb +3 -3
- data/spec/unit/loga_spec.rb +6 -3
- metadata +44 -7
@@ -20,6 +20,7 @@ describe Loga::Formatters::SimpleFormatter do
|
|
20
20
|
|
21
21
|
context 'when the message parameter is a nil' do
|
22
22
|
let(:message) { nil }
|
23
|
+
|
23
24
|
specify do
|
24
25
|
expect(subject).to eq("I, #{time_pid} nil\n")
|
25
26
|
end
|
@@ -100,7 +101,9 @@ describe Loga::Formatters::SimpleFormatter do
|
|
100
101
|
let(:tags) { %w[USER_54321 EmailWorker] }
|
101
102
|
|
102
103
|
before do
|
104
|
+
# rubocop:disable RSpec/AnyInstance
|
103
105
|
allow_any_instance_of(described_class).to receive(:current_tags).and_return(tags)
|
106
|
+
# rubocop:enable RSpec/AnyInstance
|
104
107
|
end
|
105
108
|
|
106
109
|
specify do
|
@@ -5,14 +5,15 @@ require 'loga/log_subscribers/action_mailer'
|
|
5
5
|
RSpec.describe Loga::LogSubscribers::ActionMailer do
|
6
6
|
subject(:mailer) { described_class.new }
|
7
7
|
|
8
|
-
|
9
|
-
double('event', payload: payload, duration: 0.0001, time: Time.now)
|
10
|
-
end
|
8
|
+
before { stub_loga }
|
11
9
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
let(:event) do
|
11
|
+
instance_double(
|
12
|
+
'ActiveSupport::Notifications::Event',
|
13
|
+
payload: payload,
|
14
|
+
duration: 0.0001,
|
15
|
+
time: Time.now,
|
16
|
+
)
|
16
17
|
end
|
17
18
|
|
18
19
|
describe '#deliver' do
|
@@ -25,9 +26,9 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
|
|
25
26
|
end
|
26
27
|
|
27
28
|
it 'logs an info message' do
|
28
|
-
|
29
|
-
|
29
|
+
allow(Loga.logger).to receive(:info)
|
30
30
|
mailer.deliver(event)
|
31
|
+
expect(Loga.logger).to have_received(:info).with(kind_of(Loga::Event))
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
@@ -42,9 +43,9 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
|
|
42
43
|
end
|
43
44
|
|
44
45
|
it 'logs an info message' do
|
45
|
-
|
46
|
-
|
46
|
+
allow(Loga.logger).to receive(:debug)
|
47
47
|
mailer.process(event)
|
48
|
+
expect(Loga.logger).to have_received(:debug).with(kind_of(Loga::Event))
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -60,9 +61,9 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
|
|
60
61
|
end
|
61
62
|
|
62
63
|
it 'logs an info message' do
|
63
|
-
|
64
|
-
|
64
|
+
allow(Loga.logger).to receive(:info)
|
65
65
|
mailer.receive(event)
|
66
|
+
expect(Loga.logger).to have_received(:info).with(kind_of(Loga::Event))
|
66
67
|
end
|
67
68
|
end
|
68
69
|
end
|
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'rack/test'
|
3
3
|
|
4
|
+
# rubocop:disable RSpec/SubjectStub, RSpec/MessageSpies, RSpec/VerifiedDoubles
|
4
5
|
describe Loga::Rack::Logger do
|
6
|
+
subject { described_class.new(app) }
|
7
|
+
|
5
8
|
let(:env) { Rack::MockRequest.env_for('/about_us?limit=1', options) }
|
6
9
|
let(:options) { {} }
|
7
10
|
let(:app) { ->(_env) { [response_status, {}, ''] } }
|
@@ -18,8 +21,6 @@ describe Loga::Rack::Logger do
|
|
18
21
|
)
|
19
22
|
end
|
20
23
|
|
21
|
-
subject { described_class.new(app) }
|
22
|
-
|
23
24
|
before { Loga.instance_variable_set(:@configuration, configuration) }
|
24
25
|
|
25
26
|
shared_examples 'logs the event' do |details|
|
@@ -54,8 +55,9 @@ describe Loga::Rack::Logger do
|
|
54
55
|
end
|
55
56
|
|
56
57
|
it "logs the Loga::Event with severity #{details[:level]}" do
|
57
|
-
|
58
|
+
allow(logger).to receive(level)
|
58
59
|
subject.call(env)
|
60
|
+
expect(logger).to have_received(level).with(an_instance_of(Loga::Event))
|
59
61
|
end
|
60
62
|
end
|
61
63
|
|
@@ -96,7 +98,7 @@ describe Loga::Rack::Logger do
|
|
96
98
|
include_examples 'logs the event', level: :info
|
97
99
|
end
|
98
100
|
|
99
|
-
context 'when the exception is on rack.exception'
|
101
|
+
context 'when the exception is on rack.exception' do
|
100
102
|
let(:response_status) { 500 }
|
101
103
|
let(:exception) { StandardError }
|
102
104
|
let(:logged_exception) { exception }
|
@@ -124,12 +126,14 @@ describe Loga::Rack::Logger do
|
|
124
126
|
let(:tags) { [:foo] }
|
125
127
|
|
126
128
|
it 'yields the app with tags' do
|
127
|
-
|
129
|
+
allow(logger).to receive(:tagged)
|
130
|
+
subject.call(env)
|
131
|
+
expect(logger).to have_received(:tagged).with(:tag) do |&block|
|
128
132
|
expect(block.call).to eq(:response)
|
129
133
|
end
|
130
|
-
subject.call(env)
|
131
134
|
end
|
132
135
|
end
|
133
136
|
end
|
134
137
|
end
|
135
138
|
end
|
139
|
+
# rubocop:enable RSpec/SubjectStub, RSpec/MessageSpies, RSpec/VerifiedDoubles
|
@@ -1,6 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Loga::Rack::Request do
|
4
|
+
subject { described_class.new(env) }
|
5
|
+
|
4
6
|
let(:options) { {} }
|
5
7
|
let(:full_path) { '/' }
|
6
8
|
let(:env) { Rack::MockRequest.env_for(full_path, options) }
|
@@ -23,8 +25,6 @@ describe Loga::Rack::Request do
|
|
23
25
|
allow(Loga).to receive(:configuration).and_return(config)
|
24
26
|
end
|
25
27
|
|
26
|
-
subject { described_class.new(env) }
|
27
|
-
|
28
28
|
describe '#uuid' do
|
29
29
|
let(:action_dispatch_request_id) { 'ABCD' }
|
30
30
|
|
@@ -32,6 +32,7 @@ describe Loga::Rack::Request do
|
|
32
32
|
let(:options) do
|
33
33
|
{ 'action_dispatch.request_id' => action_dispatch_request_id }
|
34
34
|
end
|
35
|
+
|
35
36
|
it 'returns the middleware value' do
|
36
37
|
expect(subject.uuid).to eq(action_dispatch_request_id)
|
37
38
|
end
|
@@ -90,7 +91,7 @@ describe Loga::Rack::Request do
|
|
90
91
|
|
91
92
|
let(:options) { { 'loga.request.original_path' => path } }
|
92
93
|
|
93
|
-
|
94
|
+
describe 'request with sensitive parameters' do
|
94
95
|
it 'returns the path with sensitive parameters filtered' do
|
95
96
|
expect(subject.filtered_full_path).to eq('/hello?password=[FILTERED]&color=red')
|
96
97
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Loga::Utilities do
|
4
|
-
subject { Object.new.extend(
|
4
|
+
subject { Object.new.extend(described_class) }
|
5
5
|
|
6
6
|
describe 'duration_in_ms#(started_at, ended_at)' do
|
7
|
+
subject { super().duration_in_ms(start_time, end_time) }
|
8
|
+
|
7
9
|
let(:start_time) { Time.new(2002, 10, 31, 2, 2, 2.0) }
|
8
10
|
let(:end_time) { Time.new(2002, 10, 31, 2, 2, 2.6789) }
|
9
11
|
|
10
|
-
subject { super().duration_in_ms(start_time, end_time) }
|
11
|
-
|
12
12
|
it 'calculates elapsed time rounding the nearest millisecond' do
|
13
13
|
expect(subject).to eq(679)
|
14
14
|
end
|
data/spec/unit/loga_spec.rb
CHANGED
@@ -12,15 +12,17 @@ describe Loga do
|
|
12
12
|
|
13
13
|
describe '.configure' do
|
14
14
|
it 'configures Loga' do
|
15
|
-
|
15
|
+
allow(Loga::Configuration).to receive(:new).and_call_original
|
16
16
|
subject.configure(options)
|
17
|
+
expect(Loga::Configuration).to have_received(:new).with(options, {})
|
17
18
|
end
|
18
19
|
|
19
20
|
context 'when framework options provided' do
|
20
21
|
it 'configures Loga' do
|
21
|
-
|
22
|
-
.to receive(:new).with(options, framework_options).and_call_original
|
22
|
+
allow(Loga::Configuration).to receive(:new).and_call_original
|
23
23
|
subject.configure(options, framework_options)
|
24
|
+
expect(Loga::Configuration).to have_received(:new)
|
25
|
+
.with(options, framework_options)
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
@@ -61,6 +63,7 @@ describe Loga do
|
|
61
63
|
|
62
64
|
context 'when Loga is configured' do
|
63
65
|
before { subject.configure(options) }
|
66
|
+
|
64
67
|
specify { expect(subject.logger).to be_kind_of(Logger) }
|
65
68
|
end
|
66
69
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Funding Circle
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,34 +164,62 @@ dependencies:
|
|
164
164
|
- - ">="
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '0'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: fakeredis
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
- !ruby/object:Gem::Dependency
|
168
182
|
name: rspec
|
169
183
|
requirement: !ruby/object:Gem::Requirement
|
170
184
|
requirements:
|
171
185
|
- - "~>"
|
172
186
|
- !ruby/object:Gem::Version
|
173
|
-
version: 3.
|
187
|
+
version: 3.7.0
|
174
188
|
type: :development
|
175
189
|
prerelease: false
|
176
190
|
version_requirements: !ruby/object:Gem::Requirement
|
177
191
|
requirements:
|
178
192
|
- - "~>"
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: 3.
|
194
|
+
version: 3.7.0
|
181
195
|
- !ruby/object:Gem::Dependency
|
182
196
|
name: rubocop
|
183
197
|
requirement: !ruby/object:Gem::Requirement
|
184
198
|
requirements:
|
185
199
|
- - "~>"
|
186
200
|
- !ruby/object:Gem::Version
|
187
|
-
version: 0.
|
201
|
+
version: 0.57.0
|
188
202
|
type: :development
|
189
203
|
prerelease: false
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
191
205
|
requirements:
|
192
206
|
- - "~>"
|
193
207
|
- !ruby/object:Gem::Version
|
194
|
-
version: 0.
|
208
|
+
version: 0.57.0
|
209
|
+
- !ruby/object:Gem::Dependency
|
210
|
+
name: rubocop-rspec
|
211
|
+
requirement: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
|
+
type: :development
|
217
|
+
prerelease: false
|
218
|
+
version_requirements: !ruby/object:Gem::Requirement
|
219
|
+
requirements:
|
220
|
+
- - ">="
|
221
|
+
- !ruby/object:Gem::Version
|
222
|
+
version: '0'
|
195
223
|
- !ruby/object:Gem::Dependency
|
196
224
|
name: timecop
|
197
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -231,6 +259,7 @@ files:
|
|
231
259
|
- gemfiles/rails42.gemfile
|
232
260
|
- gemfiles/rails50.gemfile
|
233
261
|
- gemfiles/rails52.gemfile
|
262
|
+
- gemfiles/sidekiq51.gemfile
|
234
263
|
- gemfiles/sinatra14.gemfile
|
235
264
|
- gemfiles/unit.gemfile
|
236
265
|
- lib/loga.rb
|
@@ -249,6 +278,8 @@ files:
|
|
249
278
|
- lib/loga/rack/request_id.rb
|
250
279
|
- lib/loga/railtie.rb
|
251
280
|
- lib/loga/service_version_strategies.rb
|
281
|
+
- lib/loga/sidekiq.rb
|
282
|
+
- lib/loga/sidekiq/job_logger.rb
|
252
283
|
- lib/loga/tagged_logging.rb
|
253
284
|
- lib/loga/utilities.rb
|
254
285
|
- lib/loga/version.rb
|
@@ -263,7 +294,10 @@ files:
|
|
263
294
|
- spec/integration/rails/action_mailer_spec.rb
|
264
295
|
- spec/integration/rails/railtie_spec.rb
|
265
296
|
- spec/integration/rails/request_spec.rb
|
297
|
+
- spec/integration/sidekiq_spec.rb
|
266
298
|
- spec/integration/sinatra_spec.rb
|
299
|
+
- spec/loga/sidekiq/job_logger_spec.rb
|
300
|
+
- spec/loga/sidekiq_spec.rb
|
267
301
|
- spec/spec_helper.rb
|
268
302
|
- spec/support/gethostname_shared.rb
|
269
303
|
- spec/support/helpers.rb
|
@@ -300,7 +334,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
334
|
version: '0'
|
301
335
|
requirements: []
|
302
336
|
rubyforge_project:
|
303
|
-
rubygems_version: 2.7.
|
337
|
+
rubygems_version: 2.7.7
|
304
338
|
signing_key:
|
305
339
|
specification_version: 4
|
306
340
|
summary: Facilitate log aggregation via unified logging
|
@@ -315,7 +349,10 @@ test_files:
|
|
315
349
|
- spec/integration/rails/action_mailer_spec.rb
|
316
350
|
- spec/integration/rails/railtie_spec.rb
|
317
351
|
- spec/integration/rails/request_spec.rb
|
352
|
+
- spec/integration/sidekiq_spec.rb
|
318
353
|
- spec/integration/sinatra_spec.rb
|
354
|
+
- spec/loga/sidekiq/job_logger_spec.rb
|
355
|
+
- spec/loga/sidekiq_spec.rb
|
319
356
|
- spec/spec_helper.rb
|
320
357
|
- spec/support/gethostname_shared.rb
|
321
358
|
- spec/support/helpers.rb
|