loga 2.8.0 → 2.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/build-and-test.yml +72 -0
  3. data/.github/workflows/publish-gem.yml +28 -0
  4. data/.rubocop.yml +4 -0
  5. data/.rubocop_todo.yml +206 -0
  6. data/Appraisals +58 -46
  7. data/CHANGELOG.md +6 -0
  8. data/Gemfile +22 -0
  9. data/gemfiles/rails52.gemfile +23 -1
  10. data/gemfiles/rails60.gemfile +22 -0
  11. data/gemfiles/rails61.gemfile +22 -0
  12. data/gemfiles/rails70.gemfile +24 -0
  13. data/gemfiles/rails71.gemfile +35 -0
  14. data/gemfiles/sidekiq51.gemfile +22 -0
  15. data/gemfiles/sidekiq60.gemfile +22 -0
  16. data/gemfiles/sidekiq61.gemfile +22 -0
  17. data/gemfiles/sidekiq62.gemfile +22 -0
  18. data/gemfiles/sidekiq63.gemfile +22 -0
  19. data/gemfiles/sidekiq64.gemfile +22 -0
  20. data/gemfiles/sidekiq65.gemfile +22 -0
  21. data/gemfiles/sidekiq7.gemfile +22 -0
  22. data/gemfiles/sidekiq70.gemfile +22 -0
  23. data/gemfiles/sidekiq71.gemfile +22 -0
  24. data/gemfiles/sinatra14.gemfile +22 -0
  25. data/gemfiles/sinatra2.gemfile +33 -0
  26. data/gemfiles/sinatra3.gemfile +33 -0
  27. data/gemfiles/sinatra4.gemfile +33 -0
  28. data/gemfiles/unit.gemfile +22 -0
  29. data/lib/loga/railtie.rb +2 -2
  30. data/lib/loga/version.rb +1 -1
  31. data/loga.gemspec +0 -15
  32. data/spec/fixtures/{rails50.rb → rails71.rb} +1 -1
  33. data/spec/integration/rails/action_mailer_spec.rb +2 -0
  34. data/spec/integration/rails/railtie_spec.rb +13 -3
  35. data/spec/integration/rails/request_spec.rb +4 -2
  36. data/spec/integration/sidekiq5_spec.rb +15 -13
  37. data/spec/integration/sidekiq60_spec.rb +3 -3
  38. data/spec/integration/sidekiq61_spec.rb +6 -4
  39. data/spec/integration/sidekiq65_spec.rb +1 -1
  40. data/spec/integration/sinatra_spec.rb +9 -6
  41. data/spec/loga/sidekiq5/job_logger_spec.rb +2 -0
  42. data/spec/loga/sidekiq6/job_logger_spec.rb +3 -1
  43. data/spec/loga/sidekiq7/job_logger_spec.rb +3 -1
  44. data/spec/loga/sidekiq_spec.rb +4 -2
  45. data/spec/spec_helper.rb +6 -3
  46. data/spec/support/gethostname_shared.rb +3 -1
  47. data/spec/support/helpers.rb +2 -0
  48. data/spec/support/request_spec.rb +83 -81
  49. data/spec/support/timecop_shared.rb +3 -1
  50. data/spec/unit/loga/configuration_spec.rb +11 -9
  51. data/spec/unit/loga/event_spec.rb +4 -2
  52. data/spec/unit/loga/formatters/gelf_formatter_spec.rb +15 -13
  53. data/spec/unit/loga/formatters/simple_formatter_spec.rb +7 -5
  54. data/spec/unit/loga/log_subscribers/action_mailer_spec.rb +6 -4
  55. data/spec/unit/loga/parameter_filter_spec.rb +2 -0
  56. data/spec/unit/loga/rack/logger_spec.rb +18 -16
  57. data/spec/unit/loga/rack/request_spec.rb +2 -0
  58. data/spec/unit/loga/service_version_strategies_spec.rb +2 -0
  59. data/spec/unit/loga/utilities_spec.rb +2 -0
  60. data/spec/unit/loga_spec.rb +3 -1
  61. metadata +12 -206
  62. data/.circleci/config.yml +0 -112
  63. data/gemfiles/rails42.gemfile +0 -11
  64. data/gemfiles/rails50.gemfile +0 -11
  65. data/spec/fixtures/rails42.rb +0 -80
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  class MySinatraApp < Sinatra::Base
@@ -21,7 +23,7 @@ class MySinatraApp < Sinatra::Base
21
23
  end
22
24
  end
23
25
 
24
- RSpec.describe 'Structured logging with Sinatra', :with_hostname, :timecop do
26
+ RSpec.describe 'Structured logging with Sinatra', :timecop, :with_hostname do
25
27
  let(:io) { StringIO.new }
26
28
  let(:format) {}
27
29
  let(:last_log_entry) do
@@ -69,12 +71,12 @@ RSpec.describe 'Structured logging with Sinatra', :with_hostname, :timecop do
69
71
  let(:data) do
70
72
  {
71
73
  'method' => 'GET',
72
- 'path' => '/ok',
74
+ 'path' => '/ok',
73
75
  'params' => { 'username'=>'yoshi' },
74
76
  'request_id' => '700a6a01',
75
77
  'request_ip' => '127.0.0.1',
76
78
  'user_agent' => nil,
77
- 'duration' => 0,
79
+ 'duration' => 0,
78
80
  'status' => 200,
79
81
  }
80
82
  end
@@ -97,7 +99,7 @@ RSpec.describe 'Structured logging with Sinatra', :with_hostname, :timecop do
97
99
  let(:data) do
98
100
  super().merge(
99
101
  'status' => 302,
100
- 'path' => '/new',
102
+ 'path' => '/new',
101
103
  'params' => {},
102
104
  )
103
105
  end
@@ -112,14 +114,15 @@ RSpec.describe 'Structured logging with Sinatra', :with_hostname, :timecop do
112
114
  let(:data) do
113
115
  super().merge(
114
116
  'status' => 500,
115
- 'path' => '/error',
117
+ 'path' => '/error',
116
118
  'params' => {},
117
119
  )
118
120
  end
119
121
 
120
122
  it 'logs the request with the exception' do
121
123
  get '/error', {}, 'HTTP_X_REQUEST_ID' => '700a6a01'
122
- expect(last_log_entry).to eql("E, #{time_pid_tags} GET /error 500 in 0ms type=request #{data_as_text} exception=undefined method `name' for nil:NilClass\n")
124
+
125
+ expect(last_log_entry).to start_with("E, #{time_pid_tags} GET /error 500 in 0ms type=request #{data_as_text} exception=undefined method `name' for nil")
123
126
  end
124
127
  end
125
128
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'loga/sidekiq5/job_logger'
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'loga/sidekiq6/job_logger'
3
5
 
@@ -24,7 +26,7 @@ RSpec.describe Loga::Sidekiq6::JobLogger do
24
26
 
25
27
  # https://github.com/mperham/sidekiq/blob/v6.1.2/lib/sidekiq/job_logger.rb
26
28
  it 'inherits from ::Sidekiq::JobLogger' do
27
- expect(subject).to be_a(::Sidekiq::JobLogger)
29
+ expect(subject).to be_a(Sidekiq::JobLogger)
28
30
  end
29
31
 
30
32
  describe '#call' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'loga/sidekiq7/job_logger'
3
5
 
@@ -26,7 +28,7 @@ RSpec.describe Loga::Sidekiq7::JobLogger do
26
28
 
27
29
  # https://github.com/mperham/sidekiq/blob/v6.1.2/lib/sidekiq/job_logger.rb
28
30
  it 'inherits from ::Sidekiq::JobLogger' do
29
- expect(subject).to be_a(::Sidekiq::JobLogger)
31
+ expect(subject).to be_a(Sidekiq::JobLogger)
30
32
  end
31
33
 
32
34
  describe '#call' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Loga::Sidekiq do
@@ -32,9 +34,9 @@ RSpec.describe Loga::Sidekiq do
32
34
 
33
35
  case m['version']
34
36
  when '51'
35
- expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq5::JobLogger)
37
+ expect(Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq5::JobLogger)
36
38
  when '6'
37
- expect(::Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq6::JobLogger)
39
+ expect(Sidekiq.options[:job_logger]).to eq(Loga::Sidekiq6::JobLogger)
38
40
  end
39
41
  end
40
42
  end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'byebug'
2
4
  require 'pry'
3
5
  require 'support/gethostname_shared'
@@ -8,16 +10,17 @@ require 'rack/test'
8
10
  require 'simplecov'
9
11
 
10
12
  SimpleCov.start do
11
- command_name "ruby-#{RUBY_VERSION}-#{File.basename(ENV['BUNDLE_GEMFILE'], '.gemfile')}"
13
+ command_name "ruby-#{RUBY_VERSION}-#{File.basename(ENV.fetch('BUNDLE_GEMFILE', nil),
14
+ '.gemfile')}"
12
15
 
13
16
  # Exclude specs from showing up in the code coverage report.
14
17
  add_filter 'spec/'
15
18
  end
16
19
 
17
- case ENV['BUNDLE_GEMFILE']
20
+ case ENV.fetch('BUNDLE_GEMFILE', nil)
18
21
  when /rails/
19
22
  rspec_pattern = 'integration/rails/**/*_spec.rb'
20
- /(?<appraisal>rails\d{2})\.gemfile/ =~ ENV['BUNDLE_GEMFILE']
23
+ /(?<appraisal>rails\d{2})\.gemfile/ =~ ENV.fetch('BUNDLE_GEMFILE', nil)
21
24
  require 'rails'
22
25
  require 'action_mailer'
23
26
  require File.expand_path("../fixtures/#{appraisal}.rb", __FILE__)
@@ -1,4 +1,6 @@
1
- shared_context 'gethostname', with_hostname: true do
1
+ # frozen_string_literal: true
2
+
3
+ shared_context 'gethostname', :with_hostname do
2
4
  let(:hostname) { 'bird.example.com' }
3
5
 
4
6
  before do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bigdecimal'
2
4
 
3
5
  module Helpers
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  RSpec.shared_examples 'request logger' do
2
4
  describe 'get request' do
3
5
  it 'logs the request' do
@@ -6,23 +8,23 @@ RSpec.shared_examples 'request logger' do
6
8
  'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc'
7
9
 
8
10
  expect(last_log_entry).to include(
9
- 'version' => '1.1',
10
- 'host' => 'bird.example.com',
11
- 'short_message' => 'GET /ok?username=yoshi 200 in 0ms',
12
- 'timestamp' => 1_450_150_205.123,
13
- 'level' => 6,
14
- '_type' => 'request',
15
- '_service.name' => 'hello_world_app',
16
- '_service.version' => '1.0',
17
- '_request.method' => 'GET',
18
- '_request.path' => '/ok',
19
- '_request.params' => { 'username' => 'yoshi' },
11
+ 'version' => '1.1',
12
+ 'host' => 'bird.example.com',
13
+ 'short_message' => 'GET /ok?username=yoshi 200 in 0ms',
14
+ 'timestamp' => 1_450_150_205.123,
15
+ 'level' => 6,
16
+ '_type' => 'request',
17
+ '_service.name' => 'hello_world_app',
18
+ '_service.version' => '1.0',
19
+ '_request.method' => 'GET',
20
+ '_request.path' => '/ok',
21
+ '_request.params' => { 'username' => 'yoshi' },
20
22
  '_request.request_ip' => '127.0.0.1',
21
23
  '_request.user_agent' => 'Chrome',
22
- '_request.status' => 200,
24
+ '_request.status' => 200,
23
25
  '_request.request_id' => '471a34dc',
24
- '_request.duration' => 0,
25
- '_tags' => '471a34dc TEST_TAG',
26
+ '_request.duration' => 0,
27
+ '_tags' => '471a34dc TEST_TAG',
26
28
  )
27
29
  end
28
30
  end
@@ -36,23 +38,23 @@ RSpec.shared_examples 'request logger' do
36
38
  'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc'
37
39
 
38
40
  expect(last_log_entry).to include(
39
- 'version' => '1.1',
40
- 'host' => 'bird.example.com',
41
- 'short_message' => 'POST /users?username=yoshi 200 in 0ms',
42
- 'timestamp' => 1_450_150_205.123,
43
- 'level' => 6,
44
- '_type' => 'request',
45
- '_service.name' => 'hello_world_app',
46
- '_service.version' => '1.0',
47
- '_request.method' => 'POST',
48
- '_request.path' => '/users',
49
- '_request.params' => { 'username' => 'yoshi', 'email' => 'hello@world.com' },
41
+ 'version' => '1.1',
42
+ 'host' => 'bird.example.com',
43
+ 'short_message' => 'POST /users?username=yoshi 200 in 0ms',
44
+ 'timestamp' => 1_450_150_205.123,
45
+ 'level' => 6,
46
+ '_type' => 'request',
47
+ '_service.name' => 'hello_world_app',
48
+ '_service.version' => '1.0',
49
+ '_request.method' => 'POST',
50
+ '_request.path' => '/users',
51
+ '_request.params' => { 'username' => 'yoshi', 'email' => 'hello@world.com' },
50
52
  '_request.request_ip' => '127.0.0.1',
51
53
  '_request.user_agent' => 'Chrome',
52
- '_request.status' => 200,
54
+ '_request.status' => 200,
53
55
  '_request.request_id' => '471a34dc',
54
- '_request.duration' => 0,
55
- '_tags' => '471a34dc TEST_TAG',
56
+ '_request.duration' => 0,
57
+ '_tags' => '471a34dc TEST_TAG',
56
58
  )
57
59
  end
58
60
 
@@ -68,23 +70,23 @@ RSpec.shared_examples 'request logger' do
68
70
  get '/new', {}, 'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc'
69
71
 
70
72
  expect(last_log_entry).to include(
71
- 'version' => '1.1',
72
- 'host' => 'bird.example.com',
73
- 'short_message' => 'GET /new 302 in 0ms',
74
- 'timestamp' => 1_450_150_205.123,
75
- 'level' => 6,
76
- '_type' => 'request',
77
- '_service.name' => 'hello_world_app',
78
- '_service.version' => '1.0',
79
- '_request.method' => 'GET',
80
- '_request.path' => '/new',
81
- '_request.params' => {},
73
+ 'version' => '1.1',
74
+ 'host' => 'bird.example.com',
75
+ 'short_message' => 'GET /new 302 in 0ms',
76
+ 'timestamp' => 1_450_150_205.123,
77
+ 'level' => 6,
78
+ '_type' => 'request',
79
+ '_service.name' => 'hello_world_app',
80
+ '_service.version' => '1.0',
81
+ '_request.method' => 'GET',
82
+ '_request.path' => '/new',
83
+ '_request.params' => {},
82
84
  '_request.request_ip' => '127.0.0.1',
83
85
  '_request.user_agent' => 'Chrome',
84
- '_request.status' => 302,
86
+ '_request.status' => 302,
85
87
  '_request.request_id' => '471a34dc',
86
- '_request.duration' => 0,
87
- '_tags' => '471a34dc TEST_TAG',
88
+ '_request.duration' => 0,
89
+ '_tags' => '471a34dc TEST_TAG',
88
90
  )
89
91
  end
90
92
  end
@@ -96,26 +98,26 @@ RSpec.shared_examples 'request logger' do
96
98
  'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc'
97
99
 
98
100
  expect(last_log_entry).to include(
99
- 'version' => '1.1',
100
- 'host' => 'bird.example.com',
101
- 'short_message' => 'GET /error?username=yoshi 500 in 0ms',
102
- 'timestamp' => 1_450_150_205.123,
103
- 'level' => 3,
104
- '_type' => 'request',
105
- '_service.name' => 'hello_world_app',
106
- '_service.version' => '1.0',
107
- '_request.method' => 'GET',
108
- '_request.path' => '/error',
109
- '_request.params' => { 'username' => 'yoshi' },
110
- '_request.request_ip' => '127.0.0.1',
111
- '_request.user_agent' => 'Chrome',
112
- '_request.status' => 500,
113
- '_request.request_id' => '471a34dc',
114
- '_request.duration' => 0,
115
- '_exception.klass' => 'NoMethodError',
116
- '_exception.message' => "undefined method `name' for nil:NilClass",
101
+ 'version' => '1.1',
102
+ 'host' => 'bird.example.com',
103
+ 'short_message' => 'GET /error?username=yoshi 500 in 0ms',
104
+ 'timestamp' => 1_450_150_205.123,
105
+ 'level' => 3,
106
+ '_type' => 'request',
107
+ '_service.name' => 'hello_world_app',
108
+ '_service.version' => '1.0',
109
+ '_request.method' => 'GET',
110
+ '_request.path' => '/error',
111
+ '_request.params' => { 'username' => 'yoshi' },
112
+ '_request.request_ip' => '127.0.0.1',
113
+ '_request.user_agent' => 'Chrome',
114
+ '_request.status' => 500,
115
+ '_request.request_id' => '471a34dc',
116
+ '_request.duration' => 0,
117
+ '_exception.klass' => 'NoMethodError',
118
+ '_exception.message' => start_with("undefined method `name' for nil"),
117
119
  '_exception.backtrace' => be_a(String),
118
- '_tags' => '471a34dc TEST_TAG',
120
+ '_tags' => '471a34dc TEST_TAG',
119
121
  )
120
122
  end
121
123
  end
@@ -125,23 +127,23 @@ RSpec.shared_examples 'request logger' do
125
127
  get '/not_found', {}, 'HTTP_X_REQUEST_ID' => '471a34dc'
126
128
 
127
129
  expect(last_log_entry).to include(
128
- 'version' => '1.1',
129
- 'host' => 'bird.example.com',
130
- 'short_message' => 'GET /not_found 404 in 0ms',
131
- 'timestamp' => 1_450_150_205.123,
132
- 'level' => 6,
133
- '_type' => 'request',
134
- '_service.name' => 'hello_world_app',
135
- '_service.version' => '1.0',
136
- '_request.method' => 'GET',
137
- '_request.path' => '/not_found',
138
- '_request.params' => {},
139
- '_request.request_ip' => '127.0.0.1',
140
- '_request.user_agent' => nil,
141
- '_request.status' => 404,
142
- '_request.request_id' => '471a34dc',
143
- '_request.duration' => 0,
144
- '_tags' => '471a34dc TEST_TAG',
130
+ 'version' => '1.1',
131
+ 'host' => 'bird.example.com',
132
+ 'short_message' => 'GET /not_found 404 in 0ms',
133
+ 'timestamp' => 1_450_150_205.123,
134
+ 'level' => 6,
135
+ '_type' => 'request',
136
+ '_service.name' => 'hello_world_app',
137
+ '_service.version' => '1.0',
138
+ '_request.method' => 'GET',
139
+ '_request.path' => '/not_found',
140
+ '_request.params' => {},
141
+ '_request.request_ip' => '127.0.0.1',
142
+ '_request.user_agent' => nil,
143
+ '_request.status' => 404,
144
+ '_request.request_id' => '471a34dc',
145
+ '_request.duration' => 0,
146
+ '_tags' => '471a34dc TEST_TAG',
145
147
  )
146
148
  end
147
149
  end
@@ -188,9 +190,9 @@ RSpec.shared_examples 'request logger' do
188
190
  bob_file: Rack::Test::UploadedFile.new('spec/fixtures/random_bin')
189
191
 
190
192
  expect(last_log_entry).to include(
191
- 'short_message' => 'POST /users?username=yoshi 200 in 0ms',
192
- 'level' => 6,
193
- '_request.params' => {
193
+ 'short_message' => 'POST /users?username=yoshi 200 in 0ms',
194
+ 'level' => 6,
195
+ '_request.params' => {
194
196
  'username' => 'yoshi',
195
197
  'bob_file' => include(
196
198
  'filename' => 'random_bin',
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'timecop'
2
4
 
3
- shared_context 'timecop', timecop: true do
5
+ shared_context 'timecop', :timecop do
4
6
  # Allows fixed timestamps
5
7
  before(:all) { Timecop.freeze(time_anchor) }
6
8
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Loga::Configuration do
@@ -20,8 +22,8 @@ describe Loga::Configuration do
20
22
  allow(Loga::ServiceVersionStrategies).to receive(:call).and_return('unknown.sha')
21
23
  end
22
24
 
23
- context 'defaults', with_hostname: true do
24
- specify { expect(subject.device).to eq(STDOUT) }
25
+ context 'defaults', :with_hostname do
26
+ specify { expect(subject.device).to eq($stdout) }
25
27
  specify { expect(subject.filter_exceptions).to eq(framework_exceptions) }
26
28
  specify { expect(subject.filter_parameters).to eq([]) }
27
29
  specify { expect(subject.format).to eq(:simple) }
@@ -29,7 +31,7 @@ describe Loga::Configuration do
29
31
  specify { expect(subject.level).to eq(:info) }
30
32
  specify { expect(subject.service_name).to eq('hello_world_app') }
31
33
  specify { expect(subject.service_version).to eq('unknown.sha') }
32
- specify { expect(subject.sync).to eq(true) }
34
+ specify { expect(subject.sync).to be(true) }
33
35
  specify { expect(subject.tags).to eq([]) }
34
36
  end
35
37
 
@@ -174,11 +176,11 @@ describe Loga::Configuration do
174
176
  let(:logdev) { subject.logger.instance_variable_get(:@logdev) }
175
177
 
176
178
  {
177
- debug: 0,
178
- info: 1,
179
- warn: 2,
180
- error: 3,
181
- fatal: 4,
179
+ debug: 0,
180
+ info: 1,
181
+ warn: 2,
182
+ error: 3,
183
+ fatal: 4,
182
184
  unknown: 5,
183
185
  }.each do |sym, level|
184
186
  context "when log level is #{sym}" do
@@ -194,7 +196,7 @@ describe Loga::Configuration do
194
196
  let(:options) { super().merge(sync: false) }
195
197
 
196
198
  it 'uses warn log level' do
197
- expect(logdev.dev.sync).to eq(false)
199
+ expect(logdev.dev.sync).to be(false)
198
200
  end
199
201
  end
200
202
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
- RSpec.describe Loga::Event, timecop: true do
5
+ RSpec.describe Loga::Event, :timecop do
4
6
  describe 'initialize' do
5
7
  context 'when no message is passed' do
6
8
  it 'sets message to an empty string' do
@@ -9,7 +11,7 @@ RSpec.describe Loga::Event, timecop: true do
9
11
  end
10
12
 
11
13
  context 'when message is passed' do
12
- let(:message) { "stuff \xC2".force_encoding 'ASCII-8BIT' }
14
+ let(:message) { "stuff \xC2".dup.force_encoding 'ASCII-8BIT' }
13
15
  let(:subject) { described_class.new message: message }
14
16
 
15
17
  it 'sanitizes the input to be UTF-8 convertable' do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe Loga::Formatters::GELFFormatter do
@@ -8,25 +10,25 @@ describe Loga::Formatters::GELFFormatter do
8
10
  let(:host) { 'www.example.com' }
9
11
  let(:params) do
10
12
  {
11
- service_name: service_name,
13
+ service_name: service_name,
12
14
  service_version: service_version,
13
- host: host,
15
+ host: host,
14
16
  }
15
17
  end
16
18
 
17
19
  shared_examples 'valid GELF message' do
18
20
  it 'includes the required fields' do
19
- expect(json).to include('version' => '1.1',
20
- 'host' => host,
21
+ expect(json).to include('version' => '1.1',
22
+ 'host' => host,
21
23
  'short_message' => be_a(String),
22
- 'timestamp' => be_a(Float),
23
- 'level' => 6)
24
+ 'timestamp' => be_a(Float),
25
+ 'level' => 6)
24
26
  end
25
27
 
26
28
  it 'includes Loga additional fields' do
27
- expect(json).to include('_service.name' => service_name,
29
+ expect(json).to include('_service.name' => service_name,
28
30
  '_service.version' => service_version,
29
- '_tags' => '')
31
+ '_tags' => '')
30
32
  end
31
33
 
32
34
  it 'outputs the timestamp in seconds since UNIX epoch' do
@@ -233,11 +235,11 @@ describe Loga::Formatters::GELFFormatter do
233
235
  end
234
236
 
235
237
  {
236
- 'DEBUG' => 7,
237
- 'INFO' => 6,
238
- 'WARN' => 4,
239
- 'ERROR' => 3,
240
- 'FATAL' => 2,
238
+ 'DEBUG' => 7,
239
+ 'INFO' => 6,
240
+ 'WARN' => 4,
241
+ 'ERROR' => 3,
242
+ 'FATAL' => 2,
241
243
  'UNKNOWN' => 1,
242
244
  }.each do |ruby_severity, syslog_level|
243
245
  context "with severity #{ruby_severity}" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'loga/formatters/simple_formatter'
3
5
 
@@ -112,11 +114,11 @@ describe Loga::Formatters::SimpleFormatter do
112
114
  end
113
115
 
114
116
  {
115
- 'DEBUG' => 'D',
116
- 'INFO' => 'I',
117
- 'WARN' => 'W',
118
- 'ERROR' => 'E',
119
- 'FATAL' => 'F',
117
+ 'DEBUG' => 'D',
118
+ 'INFO' => 'I',
119
+ 'WARN' => 'W',
120
+ 'ERROR' => 'E',
121
+ 'FATAL' => 'F',
120
122
  'UNKNOWN' => 'U',
121
123
  }.each do |ruby_severity, formatted_severity|
122
124
  context "with severity #{ruby_severity}" do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'active_support'
3
5
  require 'loga/log_subscribers/action_mailer'
@@ -9,7 +11,7 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
9
11
 
10
12
  let(:event) do
11
13
  instance_double(
12
- 'ActiveSupport::Notifications::Event',
14
+ ActiveSupport::Notifications::Event,
13
15
  payload: payload,
14
16
  duration: 0.0001,
15
17
  time: Time.now,
@@ -21,7 +23,7 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
21
23
  let(:payload) do
22
24
  {
23
25
  mailer: 'FakeMailer',
24
- to: ['user@example.com'],
26
+ to: ['user@example.com'],
25
27
  }
26
28
  end
27
29
  let(:config) { instance_double Loga::Configuration, hide_pii: hide_pii }
@@ -82,8 +84,8 @@ RSpec.describe Loga::LogSubscribers::ActionMailer do
82
84
  context 'when an email is sent' do
83
85
  let(:payload) do
84
86
  {
85
- mailer: 'FakeMailer',
86
- from: 'loremipsum@example.com',
87
+ mailer: 'FakeMailer',
88
+ from: 'loremipsum@example.com',
87
89
  subject: 'Lorem ipsum',
88
90
  }
89
91
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  RSpec.describe Loga::ParameterFilter do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
  require 'rack/test'
3
5
 
@@ -40,22 +42,22 @@ describe Loga::Rack::Logger do
40
42
  middleware.call(env, started_at)
41
43
 
42
44
  expect(Loga::Event).to have_received(:new).with(
43
- data: {
45
+ data: {
44
46
  request: {
45
- 'status' => response_status,
46
- 'method' => 'GET',
47
- 'path' => '/about_us',
48
- 'params' => { 'limit' => '1' },
47
+ 'status' => response_status,
48
+ 'method' => 'GET',
49
+ 'path' => '/about_us',
50
+ 'params' => { 'limit' => '1' },
49
51
  'request_id' => nil,
50
52
  'request_ip' => nil,
51
53
  'user_agent' => nil,
52
- 'duration' => 500,
54
+ 'duration' => 500,
53
55
  },
54
56
  },
55
57
  exception: logged_exception,
56
- message: %r{^GET \/about_us\?limit=1 #{response_status} in \d+ms$},
58
+ message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$},
57
59
  timestamp: started_at,
58
- type: 'request',
60
+ type: 'request',
59
61
  )
60
62
  end
61
63
 
@@ -82,22 +84,22 @@ describe Loga::Rack::Logger do
82
84
  expect { middleware.call(env, started_at) }.to raise_error(exception_class)
83
85
 
84
86
  expect(Loga::Event).to have_received(:new).with(
85
- data: {
87
+ data: {
86
88
  request: {
87
- 'status' => response_status,
88
- 'method' => 'GET',
89
- 'path' => '/about_us',
90
- 'params' => { 'limit' => '1' },
89
+ 'status' => response_status,
90
+ 'method' => 'GET',
91
+ 'path' => '/about_us',
92
+ 'params' => { 'limit' => '1' },
91
93
  'request_id' => nil,
92
94
  'request_ip' => nil,
93
95
  'user_agent' => nil,
94
- 'duration' => 500,
96
+ 'duration' => 500,
95
97
  },
96
98
  },
97
99
  exception: logged_exception,
98
- message: %r{^GET \/about_us\?limit=1 #{response_status} in \d+ms$},
100
+ message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$},
99
101
  timestamp: started_at,
100
- type: 'request',
102
+ type: 'request',
101
103
  )
102
104
  end
103
105
  end