loga 2.8.0 → 2.9.0
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 +4 -4
- data/.github/workflows/build-and-test.yml +72 -0
- data/.github/workflows/publish-gem.yml +28 -0
- data/.rubocop.yml +10 -11
- data/.rubocop_todo.yml +265 -0
- data/Appraisals +83 -22
- data/CHANGELOG.md +14 -0
- data/Gemfile +24 -0
- data/README.md +1 -1
- data/gemfiles/rails52.gemfile +23 -1
- data/gemfiles/rails60.gemfile +24 -0
- data/gemfiles/rails61.gemfile +24 -0
- data/gemfiles/rails70.gemfile +27 -0
- data/gemfiles/rails71.gemfile +38 -0
- data/gemfiles/rails72.gemfile +38 -0
- data/gemfiles/rails80.gemfile +38 -0
- data/gemfiles/sidekiq51.gemfile +25 -0
- data/gemfiles/sidekiq60.gemfile +25 -0
- data/gemfiles/sidekiq61.gemfile +25 -0
- data/gemfiles/sidekiq62.gemfile +25 -0
- data/gemfiles/sidekiq63.gemfile +25 -0
- data/gemfiles/sidekiq64.gemfile +25 -0
- data/gemfiles/sidekiq65.gemfile +25 -0
- data/gemfiles/sidekiq70.gemfile +25 -0
- data/gemfiles/sidekiq71.gemfile +25 -0
- data/gemfiles/sidekiq72.gemfile +36 -0
- data/gemfiles/sidekiq73.gemfile +36 -0
- data/gemfiles/sidekiq80.gemfile +36 -0
- data/gemfiles/sinatra14.gemfile +25 -0
- data/gemfiles/sinatra2.gemfile +36 -0
- data/gemfiles/sinatra3.gemfile +36 -0
- data/gemfiles/sinatra4.gemfile +36 -0
- data/gemfiles/unit.gemfile +24 -0
- data/lib/loga/parameter_filter.rb +0 -2
- data/lib/loga/rack/request.rb +2 -2
- data/lib/loga/rack/request_id.rb +2 -2
- data/lib/loga/railtie.rb +3 -3
- data/lib/loga/sidekiq.rb +11 -0
- data/lib/loga/sidekiq8/job_logger.rb +13 -0
- data/lib/loga/tagged_logging.rb +2 -2
- data/lib/loga/version.rb +1 -1
- data/loga.gemspec +0 -15
- data/spec/fixtures/{rails50.rb → rails71.rb} +1 -1
- data/spec/fixtures/{rails42.rb → rails72.rb} +3 -3
- data/spec/fixtures/rails80.rb +80 -0
- data/spec/integration/rails/action_mailer_spec.rb +2 -0
- data/spec/integration/rails/railtie_spec.rb +13 -3
- data/spec/integration/rails/request_spec.rb +4 -2
- data/spec/integration/sidekiq5_spec.rb +15 -13
- data/spec/integration/sidekiq60_spec.rb +3 -3
- data/spec/integration/sidekiq61_spec.rb +6 -4
- data/spec/integration/sidekiq65_spec.rb +1 -1
- data/spec/integration/sidekiq8_spec.rb +193 -0
- data/spec/integration/sinatra_spec.rb +18 -8
- data/spec/loga/sidekiq5/job_logger_spec.rb +2 -0
- data/spec/loga/sidekiq6/job_logger_spec.rb +3 -1
- data/spec/loga/sidekiq_latest/job_logger_spec.rb +138 -0
- data/spec/loga/sidekiq_spec.rb +17 -3
- data/spec/spec_helper.rb +14 -5
- data/spec/support/gethostname_shared.rb +3 -1
- data/spec/support/helpers.rb +10 -0
- data/spec/support/request_spec.rb +90 -81
- data/spec/support/timecop_shared.rb +3 -1
- data/spec/unit/loga/configuration_spec.rb +11 -9
- data/spec/unit/loga/event_spec.rb +4 -2
- data/spec/unit/loga/formatters/gelf_formatter_spec.rb +22 -14
- data/spec/unit/loga/formatters/simple_formatter_spec.rb +27 -10
- data/spec/unit/loga/log_subscribers/action_mailer_spec.rb +6 -4
- data/spec/unit/loga/parameter_filter_spec.rb +2 -0
- data/spec/unit/loga/rack/logger_spec.rb +18 -16
- data/spec/unit/loga/rack/request_spec.rb +2 -0
- data/spec/unit/loga/service_version_strategies_spec.rb +2 -0
- data/spec/unit/loga/utilities_spec.rb +2 -0
- data/spec/unit/loga_spec.rb +3 -1
- metadata +26 -212
- data/.circleci/config.yml +0 -112
- data/gemfiles/rails42.gemfile +0 -11
- data/gemfiles/rails50.gemfile +0 -11
- data/gemfiles/sidekiq7.gemfile +0 -11
- data/spec/loga/sidekiq7/job_logger_spec.rb +0 -125
@@ -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'
|
10
|
-
'host'
|
11
|
-
'short_message'
|
12
|
-
'timestamp'
|
13
|
-
'level'
|
14
|
-
'_type'
|
15
|
-
'_service.name'
|
16
|
-
'_service.version'
|
17
|
-
'_request.method'
|
18
|
-
'_request.path'
|
19
|
-
'_request.params'
|
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'
|
24
|
+
'_request.status' => 200,
|
23
25
|
'_request.request_id' => '471a34dc',
|
24
|
-
'_request.duration'
|
25
|
-
'_tags'
|
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'
|
40
|
-
'host'
|
41
|
-
'short_message'
|
42
|
-
'timestamp'
|
43
|
-
'level'
|
44
|
-
'_type'
|
45
|
-
'_service.name'
|
46
|
-
'_service.version'
|
47
|
-
'_request.method'
|
48
|
-
'_request.path'
|
49
|
-
'_request.params'
|
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'
|
54
|
+
'_request.status' => 200,
|
53
55
|
'_request.request_id' => '471a34dc',
|
54
|
-
'_request.duration'
|
55
|
-
'_tags'
|
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'
|
72
|
-
'host'
|
73
|
-
'short_message'
|
74
|
-
'timestamp'
|
75
|
-
'level'
|
76
|
-
'_type'
|
77
|
-
'_service.name'
|
78
|
-
'_service.version'
|
79
|
-
'_request.method'
|
80
|
-
'_request.path'
|
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'
|
86
|
+
'_request.status' => 302,
|
85
87
|
'_request.request_id' => '471a34dc',
|
86
|
-
'_request.duration'
|
87
|
-
'_tags'
|
88
|
+
'_request.duration' => 0,
|
89
|
+
'_tags' => '471a34dc TEST_TAG',
|
88
90
|
)
|
89
91
|
end
|
90
92
|
end
|
@@ -95,27 +97,34 @@ RSpec.shared_examples 'request logger' do
|
|
95
97
|
{ username: 'yoshi' },
|
96
98
|
'HTTP_USER_AGENT' => 'Chrome', 'HTTP_X_REQUEST_ID' => '471a34dc'
|
97
99
|
|
100
|
+
method_missing_exception =
|
101
|
+
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('3.4.0dev')
|
102
|
+
"undefined method 'name' for nil"
|
103
|
+
else
|
104
|
+
"undefined method `name' for nil"
|
105
|
+
end
|
106
|
+
|
98
107
|
expect(last_log_entry).to include(
|
99
|
-
'version'
|
100
|
-
'host'
|
101
|
-
'short_message'
|
102
|
-
'timestamp'
|
103
|
-
'level'
|
104
|
-
'_type'
|
105
|
-
'_service.name'
|
106
|
-
'_service.version'
|
107
|
-
'_request.method'
|
108
|
-
'_request.path'
|
109
|
-
'_request.params'
|
110
|
-
'_request.request_ip'
|
111
|
-
'_request.user_agent'
|
112
|
-
'_request.status'
|
113
|
-
'_request.request_id'
|
114
|
-
'_request.duration'
|
115
|
-
'_exception.klass'
|
116
|
-
'_exception.message'
|
108
|
+
'version' => '1.1',
|
109
|
+
'host' => 'bird.example.com',
|
110
|
+
'short_message' => 'GET /error?username=yoshi 500 in 0ms',
|
111
|
+
'timestamp' => 1_450_150_205.123,
|
112
|
+
'level' => 3,
|
113
|
+
'_type' => 'request',
|
114
|
+
'_service.name' => 'hello_world_app',
|
115
|
+
'_service.version' => '1.0',
|
116
|
+
'_request.method' => 'GET',
|
117
|
+
'_request.path' => '/error',
|
118
|
+
'_request.params' => { 'username' => 'yoshi' },
|
119
|
+
'_request.request_ip' => '127.0.0.1',
|
120
|
+
'_request.user_agent' => 'Chrome',
|
121
|
+
'_request.status' => 500,
|
122
|
+
'_request.request_id' => '471a34dc',
|
123
|
+
'_request.duration' => 0,
|
124
|
+
'_exception.klass' => 'NoMethodError',
|
125
|
+
'_exception.message' => start_with(method_missing_exception),
|
117
126
|
'_exception.backtrace' => be_a(String),
|
118
|
-
'_tags'
|
127
|
+
'_tags' => '471a34dc TEST_TAG',
|
119
128
|
)
|
120
129
|
end
|
121
130
|
end
|
@@ -125,23 +134,23 @@ RSpec.shared_examples 'request logger' do
|
|
125
134
|
get '/not_found', {}, 'HTTP_X_REQUEST_ID' => '471a34dc'
|
126
135
|
|
127
136
|
expect(last_log_entry).to include(
|
128
|
-
'version'
|
129
|
-
'host'
|
130
|
-
'short_message'
|
131
|
-
'timestamp'
|
132
|
-
'level'
|
133
|
-
'_type'
|
134
|
-
'_service.name'
|
135
|
-
'_service.version'
|
136
|
-
'_request.method'
|
137
|
-
'_request.path'
|
138
|
-
'_request.params'
|
139
|
-
'_request.request_ip'
|
140
|
-
'_request.user_agent'
|
141
|
-
'_request.status'
|
142
|
-
'_request.request_id'
|
143
|
-
'_request.duration'
|
144
|
-
'_tags'
|
137
|
+
'version' => '1.1',
|
138
|
+
'host' => 'bird.example.com',
|
139
|
+
'short_message' => 'GET /not_found 404 in 0ms',
|
140
|
+
'timestamp' => 1_450_150_205.123,
|
141
|
+
'level' => 6,
|
142
|
+
'_type' => 'request',
|
143
|
+
'_service.name' => 'hello_world_app',
|
144
|
+
'_service.version' => '1.0',
|
145
|
+
'_request.method' => 'GET',
|
146
|
+
'_request.path' => '/not_found',
|
147
|
+
'_request.params' => {},
|
148
|
+
'_request.request_ip' => '127.0.0.1',
|
149
|
+
'_request.user_agent' => nil,
|
150
|
+
'_request.status' => 404,
|
151
|
+
'_request.request_id' => '471a34dc',
|
152
|
+
'_request.duration' => 0,
|
153
|
+
'_tags' => '471a34dc TEST_TAG',
|
145
154
|
)
|
146
155
|
end
|
147
156
|
end
|
@@ -188,9 +197,9 @@ RSpec.shared_examples 'request logger' do
|
|
188
197
|
bob_file: Rack::Test::UploadedFile.new('spec/fixtures/random_bin')
|
189
198
|
|
190
199
|
expect(last_log_entry).to include(
|
191
|
-
'short_message'
|
192
|
-
'level'
|
193
|
-
'_request.params'
|
200
|
+
'short_message' => 'POST /users?username=yoshi 200 in 0ms',
|
201
|
+
'level' => 6,
|
202
|
+
'_request.params' => {
|
194
203
|
'username' => 'yoshi',
|
195
204
|
'bob_file' => include(
|
196
205
|
'filename' => 'random_bin',
|
@@ -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
|
24
|
-
specify { expect(subject.device).to eq(
|
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
|
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:
|
178
|
-
info:
|
179
|
-
warn:
|
180
|
-
error:
|
181
|
-
fatal:
|
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
|
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
|
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,4 +1,7 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
4
|
+
require 'ostruct'
|
2
5
|
|
3
6
|
describe Loga::Formatters::GELFFormatter do
|
4
7
|
subject { described_class.new(params) }
|
@@ -8,25 +11,25 @@ describe Loga::Formatters::GELFFormatter do
|
|
8
11
|
let(:host) { 'www.example.com' }
|
9
12
|
let(:params) do
|
10
13
|
{
|
11
|
-
service_name:
|
14
|
+
service_name: service_name,
|
12
15
|
service_version: service_version,
|
13
|
-
host:
|
16
|
+
host: host,
|
14
17
|
}
|
15
18
|
end
|
16
19
|
|
17
20
|
shared_examples 'valid GELF message' do
|
18
21
|
it 'includes the required fields' do
|
19
|
-
expect(json).to include('version'
|
20
|
-
'host'
|
22
|
+
expect(json).to include('version' => '1.1',
|
23
|
+
'host' => host,
|
21
24
|
'short_message' => be_a(String),
|
22
|
-
'timestamp'
|
23
|
-
'level'
|
25
|
+
'timestamp' => be_a(Float),
|
26
|
+
'level' => 6)
|
24
27
|
end
|
25
28
|
|
26
29
|
it 'includes Loga additional fields' do
|
27
|
-
expect(json).to include('_service.name'
|
30
|
+
expect(json).to include('_service.name' => service_name,
|
28
31
|
'_service.version' => service_version,
|
29
|
-
'_tags'
|
32
|
+
'_tags' => '')
|
30
33
|
end
|
31
34
|
|
32
35
|
it 'outputs the timestamp in seconds since UNIX epoch' do
|
@@ -63,7 +66,12 @@ describe Loga::Formatters::GELFFormatter do
|
|
63
66
|
let(:message) { { message: 'Wooden house' } }
|
64
67
|
|
65
68
|
it 'the short_message is a String reprentation of that Hash' do
|
66
|
-
expect(json['short_message']).to eq(
|
69
|
+
expect(json['short_message']).to eq(
|
70
|
+
with_new_ruby(
|
71
|
+
test: '{message: "Wooden house"}',
|
72
|
+
else: '{:message=>"Wooden house"}',
|
73
|
+
),
|
74
|
+
)
|
67
75
|
end
|
68
76
|
|
69
77
|
include_examples 'valid GELF message'
|
@@ -233,11 +241,11 @@ describe Loga::Formatters::GELFFormatter do
|
|
233
241
|
end
|
234
242
|
|
235
243
|
{
|
236
|
-
'DEBUG'
|
237
|
-
'INFO'
|
238
|
-
'WARN'
|
239
|
-
'ERROR'
|
240
|
-
'FATAL'
|
244
|
+
'DEBUG' => 7,
|
245
|
+
'INFO' => 6,
|
246
|
+
'WARN' => 4,
|
247
|
+
'ERROR' => 3,
|
248
|
+
'FATAL' => 2,
|
241
249
|
'UNKNOWN' => 1,
|
242
250
|
}.each do |ruby_severity, syslog_level|
|
243
251
|
context "with severity #{ruby_severity}" do
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
require 'loga/formatters/simple_formatter'
|
3
5
|
|
4
|
-
# rubocop:disable
|
6
|
+
# rubocop:disable Layout/LineLength
|
5
7
|
describe Loga::Formatters::SimpleFormatter do
|
6
8
|
before { allow(Process).to receive(:pid).and_return(999) }
|
7
9
|
|
@@ -30,7 +32,12 @@ describe Loga::Formatters::SimpleFormatter do
|
|
30
32
|
let(:message) { { record: 'Wooden house' } }
|
31
33
|
|
32
34
|
specify do
|
33
|
-
expect(subject).to eq(
|
35
|
+
expect(subject).to eq(
|
36
|
+
with_new_ruby(
|
37
|
+
test: "I, #{time_pid} {record: \"Wooden house\"}\n",
|
38
|
+
else: "I, #{time_pid} {:record=>\"Wooden house\"}\n",
|
39
|
+
),
|
40
|
+
)
|
34
41
|
end
|
35
42
|
end
|
36
43
|
|
@@ -78,7 +85,12 @@ describe Loga::Formatters::SimpleFormatter do
|
|
78
85
|
end
|
79
86
|
|
80
87
|
specify do
|
81
|
-
expect(subject).to eq(
|
88
|
+
expect(subject).to eq(
|
89
|
+
with_new_ruby(
|
90
|
+
test: "I, #{time_pid} Hello World data={admin: true, user: {email: \"hello@world.com\"}}\n",
|
91
|
+
else: "I, #{time_pid} Hello World data={:admin=>true, :user=>{:email=>\"hello@world.com\"}}\n",
|
92
|
+
),
|
93
|
+
)
|
82
94
|
end
|
83
95
|
end
|
84
96
|
|
@@ -92,7 +104,12 @@ describe Loga::Formatters::SimpleFormatter do
|
|
92
104
|
end
|
93
105
|
|
94
106
|
specify do
|
95
|
-
expect(subject).to eq(
|
107
|
+
expect(subject).to eq(
|
108
|
+
with_new_ruby(
|
109
|
+
test: "I, #{time_pid} Hello World type=request data={ssl: true}\n",
|
110
|
+
else: "I, #{time_pid} Hello World type=request data={:ssl=>true}\n",
|
111
|
+
),
|
112
|
+
)
|
96
113
|
end
|
97
114
|
end
|
98
115
|
end
|
@@ -112,11 +129,11 @@ describe Loga::Formatters::SimpleFormatter do
|
|
112
129
|
end
|
113
130
|
|
114
131
|
{
|
115
|
-
'DEBUG'
|
116
|
-
'INFO'
|
117
|
-
'WARN'
|
118
|
-
'ERROR'
|
119
|
-
'FATAL'
|
132
|
+
'DEBUG' => 'D',
|
133
|
+
'INFO' => 'I',
|
134
|
+
'WARN' => 'W',
|
135
|
+
'ERROR' => 'E',
|
136
|
+
'FATAL' => 'F',
|
120
137
|
'UNKNOWN' => 'U',
|
121
138
|
}.each do |ruby_severity, formatted_severity|
|
122
139
|
context "with severity #{ruby_severity}" do
|
@@ -127,4 +144,4 @@ describe Loga::Formatters::SimpleFormatter do
|
|
127
144
|
end
|
128
145
|
end
|
129
146
|
end
|
130
|
-
# rubocop:enable
|
147
|
+
# rubocop:enable Layout/LineLength
|
@@ -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
|
-
|
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:
|
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:
|
86
|
-
from:
|
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
|
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'
|
46
|
-
'method'
|
47
|
-
'path'
|
48
|
-
'params'
|
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'
|
54
|
+
'duration' => 500,
|
53
55
|
},
|
54
56
|
},
|
55
57
|
exception: logged_exception,
|
56
|
-
message:
|
58
|
+
message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$},
|
57
59
|
timestamp: started_at,
|
58
|
-
type:
|
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'
|
88
|
-
'method'
|
89
|
-
'path'
|
90
|
-
'params'
|
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'
|
96
|
+
'duration' => 500,
|
95
97
|
},
|
96
98
|
},
|
97
99
|
exception: logged_exception,
|
98
|
-
message:
|
100
|
+
message: %r{^GET /about_us\?limit=1 #{response_status} in \d+ms$},
|
99
101
|
timestamp: started_at,
|
100
|
-
type:
|
102
|
+
type: 'request',
|
101
103
|
)
|
102
104
|
end
|
103
105
|
end
|
data/spec/unit/loga_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Loga do
|
@@ -64,7 +66,7 @@ describe Loga do
|
|
64
66
|
context 'when Loga is configured' do
|
65
67
|
before { subject.configure(options) }
|
66
68
|
|
67
|
-
specify { expect(subject.logger).to
|
69
|
+
specify { expect(subject.logger).to be_a(Logger) }
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|