Skip to content

Commit 56ff4af

Browse files
authored
Merge branch 'master' into patch-1
2 parents adf4b0b + b165bfc commit 56ff4af

6 files changed

Lines changed: 134 additions & 93 deletions

File tree

lib/rollbar/notifier.rb

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -607,26 +607,25 @@ def send_using_eventmachine(body)
607607
def eventmachine_callback(req)
608608
req.callback do
609609
if req.response_header.status == 200
610-
log_info '[Rollbar] Success'
610+
log_debug '[Rollbar] Success'
611611
else
612612
log_warning '[Rollbar] Got unexpected status code from Rollbar.io api: ' \
613-
"#{req.response_header.status}"
614-
log_info "[Rollbar] Response: #{req.response}"
613+
"#{req.response_header.status}, response: #{req.response}"
615614
end
616615
end
617616
end
618617

619618
def eventmachine_errback(req)
620619
req.errback do
621620
log_warning(
622-
"[Rollbar] Call to API failed, status code: #{req.response_header.status}"
621+
"[Rollbar] Call to API failed, status code: #{req.response_header.status}, "\
622+
"response: #{req.response}"
623623
)
624-
log_info "[Rollbar] Error's response: #{req.response}"
625624
end
626625
end
627626

628627
def send_item(item)
629-
log_info '[Rollbar] Sending item'
628+
log_debug '[Rollbar] Sending item'
630629

631630
body = item.dump
632631
return unless body
@@ -640,7 +639,7 @@ def send_item(item)
640639
end
641640

642641
def send_body(body)
643-
log_info '[Rollbar] Sending json'
642+
log_debug '[Rollbar] Sending json'
644643

645644
uri = URI.parse(configuration.endpoint)
646645

@@ -750,12 +749,12 @@ def handle_net_retries
750749

751750
def handle_response(response)
752751
if response.code == '200'
753-
log_info '[Rollbar] Success'
752+
log_debug '[Rollbar] Success'
754753
else
755754
log_warning(
756-
"[Rollbar] Got unexpected status code from Rollbar api: #{response.code}"
755+
"[Rollbar] Got unexpected status code from Rollbar api: #{response.code}, " \
756+
"response: #{response.body}"
757757
)
758-
log_info "[Rollbar] Response: #{response.body}"
759758
configuration.execute_hook(:on_error_response, response)
760759
end
761760
end
@@ -769,7 +768,7 @@ def ssl_verify_mode
769768
end
770769

771770
def do_write_item(item)
772-
log_info '[Rollbar] Writing item to file'
771+
log_debug '[Rollbar] Writing item to file'
773772

774773
body = item.dump
775774
return unless body
@@ -783,7 +782,7 @@ def do_write_item(item)
783782
@file.flush
784783
update_file(@file, file_name)
785784

786-
log_info '[Rollbar] Success'
785+
log_debug '[Rollbar] Success'
787786
rescue IOError => e
788787
log_error "[Rollbar] Error opening/writing to file: #{e}"
789788
end
@@ -846,7 +845,7 @@ def failsafe_body(reason)
846845
def schedule_item(item)
847846
return unless item
848847

849-
log_info '[Rollbar] Scheduling item'
848+
log_debug '[Rollbar] Scheduling item'
850849

851850
if configuration.use_async
852851
process_async_item(item)

spec/controllers/home_controller_spec.rb

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,22 +249,22 @@ def send_req(meth, path, args)
249249

250250
describe "GET 'index'" do
251251
it 'should be successful and report two messages' do
252-
logger_mock.should_receive(:info).with('[Rollbar] Success').twice
252+
logger_mock.should_receive(:debug).with('[Rollbar] Success').twice
253253
get 'index'
254254
expect(response.status).to eq(200)
255255
end
256256
end
257257

258258
describe "'report_exception'", :type => 'request' do
259259
it 'should raise a NameError and report an exception after a GET' do
260-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
260+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
261261

262262
get '/report_exception'
263263
expect(response.status).to eq(200)
264264
end
265265

266266
it 'should raise a NameError and have PUT params in the reported exception' do
267-
logger_mock.should_receive(:info).with('[Rollbar] Success')
267+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
268268

269269
send_req(:put, '/report_exception', wrap_process_args(:putparam => 'putval'))
270270

@@ -274,7 +274,7 @@ def send_req(meth, path, args)
274274

275275
context 'using deprecated report_exception' do
276276
it 'reports the errors successfully' do
277-
logger_mock.should_receive(:info).with('[Rollbar] Success')
277+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
278278

279279
send_req(:put, '/deprecated_report_exception',
280280
wrap_process_args(:putparam => 'putval'))
@@ -285,7 +285,7 @@ def send_req(meth, path, args)
285285
end
286286

287287
it 'should raise a NameError and have JSON POST params' do
288-
logger_mock.should_receive(:info).with('[Rollbar] Success')
288+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
289289
@request.env['HTTP_ACCEPT'] = 'application/json'
290290

291291
params = { :jsonparam => 'jsonval' }.to_json
@@ -316,7 +316,7 @@ def send_req(meth, path, args)
316316

317317
context 'when Rails Error Subscriber is enabled', if: ::Rails.gem_version >= ::Gem::Version.new('7.1.0') do
318318
it '`handle` should not raise an error and report a warning via rails error subscriber' do
319-
logger_mock.should_receive(:info).with('[Rollbar] Success').never
319+
logger_mock.should_receive(:debug).with('[Rollbar] Success').never
320320

321321
expect(Rollbar).to receive(:log) do |level, _, extra|
322322
expect(extra[:custom_data_method_context]).to be_eql('application')
@@ -327,7 +327,7 @@ def send_req(meth, path, args)
327327
end
328328

329329
it '`handle` should report a warning via rails error subscriber when capture_uncaught is false' do
330-
logger_mock.should_receive(:info).with('[Rollbar] Success').never
330+
logger_mock.should_receive(:debug).with('[Rollbar] Success').never
331331

332332
Rollbar.configure do |config|
333333
config.capture_uncaught = false
@@ -342,7 +342,7 @@ def send_req(meth, path, args)
342342
end
343343

344344
it '`report` should raise an error and report an error via rails error subscriber' do
345-
logger_mock.should_receive(:info).with('[Rollbar] Success').never
345+
logger_mock.should_receive(:debug).with('[Rollbar] Success').never
346346

347347
expect(Rollbar).to receive(:log) do |level, _, extra|
348348
expect(extra[:custom_data_method_context]).to be_eql('application')
@@ -355,7 +355,7 @@ def send_req(meth, path, args)
355355
end
356356

357357
it 'uncaught exception should raise an error and report an error via rails error subscriber' do
358-
logger_mock.should_receive(:info).with('[Rollbar] Success').never
358+
logger_mock.should_receive(:debug).with('[Rollbar] Success').never
359359

360360
expect(Rollbar).to receive(:log) do |level, _, extra|
361361
expect(extra[:custom_data_method_context]).to be_eql('application.action_dispatch')
@@ -368,7 +368,7 @@ def send_req(meth, path, args)
368368
end
369369

370370
it 'uncaught exception should not report an error when capture_uncaught is not set' do
371-
logger_mock.should_receive(:info).with('[Rollbar] Success').never
371+
logger_mock.should_receive(:debug).with('[Rollbar] Success').never
372372

373373
Rollbar.configure do |config|
374374
config.capture_uncaught = false
@@ -384,7 +384,7 @@ def send_req(meth, path, args)
384384

385385
context 'when Rails Error Subscriber is enabled in unsupported Rails', if: ::Rails.gem_version < ::Gem::Version.new('7.1.0') do
386386
it 'uncaught exception should raise an error and report via middleware' do
387-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
387+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
388388

389389
expect do
390390
get '/cause_exception'
@@ -431,7 +431,7 @@ def send_req(meth, path, args)
431431
end
432432

433433
it 'should include locals in extra data' do
434-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
434+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
435435

436436
expect {
437437
get '/cause_exception_with_locals?test_fibers=true'
@@ -468,7 +468,7 @@ def send_req(meth, path, args)
468468
end
469469

470470
it 'should not include locals in extra data' do
471-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
471+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
472472

473473
expect { get '/cause_exception_with_locals' }.to raise_exception(NoMethodError)
474474
expect(Rollbar.last_report[:body][:trace][:frames][-1][:locals]).to be_eql(nil)
@@ -478,7 +478,7 @@ def send_req(meth, path, args)
478478

479479
describe "'cause_exception'", :type => 'request' do
480480
it 'should raise an uncaught exception and report a message' do
481-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
481+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
482482

483483
expect { get '/cause_exception' }.to raise_exception(NameError)
484484
end
@@ -517,7 +517,7 @@ def send_req(meth, path, args)
517517
end
518518

519519
it 'middleware should catch the exception and only report to rollbar once' do
520-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
520+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
521521

522522
get '/cause_exception'
523523
end

spec/rollbar/middleware/sinatra_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ def app
280280
end
281281

282282
it 'should include locals in extra data' do
283-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
283+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
284284

285285
expect { get '/cause_exception_with_locals' }.to raise_exception(NoMethodError)
286286

@@ -315,7 +315,7 @@ def app
315315
end
316316

317317
it 'should not include locals in extra data' do
318-
logger_mock.should_receive(:info).with('[Rollbar] Success').once
318+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
319319

320320
expect { get '/cause_exception_with_locals' }.to raise_exception(NoMethodError)
321321
expect(Rollbar.last_report[:body][:trace][:frames][-1][:locals]).to be_eql(nil)

spec/rollbar_bc_spec.rb

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
end
2424

2525
it 'should report simple messages' do
26-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
27-
logger_mock.should_receive(:info).with('[Rollbar] Success')
26+
logger_mock.should_receive(:debug).with('[Rollbar] Scheduling item')
27+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
2828

2929
Rollbar.report_message('Test message')
3030
end
3131

3232
it 'should not report anything when disabled' do
33-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
33+
logger_mock.should_not_receive(:debug).with('[Rollbar] Success')
3434

3535
Rollbar.configure do |config|
3636
config.enabled = false
@@ -40,7 +40,7 @@
4040
end
4141

4242
it 'should report messages with extra data' do
43-
logger_mock.should_receive(:info).with('[Rollbar] Success')
43+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
4444
Rollbar.report_message(
4545
'Test message with extra data',
4646
'debug',
@@ -58,20 +58,20 @@
5858
expect(logger_mock).to_not receive(:error).with(
5959
/\[Rollbar\] Reporting internal error encountered while sending data to Rollbar./
6060
)
61-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
62-
logger_mock.should_receive(:info).with('[Rollbar] Success')
61+
logger_mock.should_receive(:debug).with('[Rollbar] Scheduling item')
62+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
6363

6464
Rollbar.error('Test message with circular extra data', a)
6565
end
6666

6767
it 'should be able to report form validation errors when they are present' do
68-
logger_mock.should_receive(:info).with('[Rollbar] Success')
68+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
6969
user.errors.add(:example, 'error')
7070
user.report_validation_errors_to_rollbar
7171
end
7272

7373
it 'should not report form validation errors when they are not present' do
74-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
74+
logger_mock.should_not_receive(:debug).with('[Rollbar] Success')
7575
user.errors.clear
7676
user.report_validation_errors_to_rollbar
7777
end
@@ -98,8 +98,8 @@
9898

9999
it 'should report simple messages' do
100100
allow(Rollbar).to receive(:notifier).and_return(notifier)
101-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
102-
logger_mock.should_receive(:info).with('[Rollbar] Success')
101+
logger_mock.should_receive(:debug).with('[Rollbar] Scheduling item')
102+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
103103
Rollbar.report_message_with_request('Test message')
104104

105105
Rollbar.last_report[:request].should be_nil
@@ -109,8 +109,8 @@
109109
it 'should report messages with request, person data and extra data' do
110110
Rollbar.last_report = nil
111111

112-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling item')
113-
logger_mock.should_receive(:info).with('[Rollbar] Success')
112+
logger_mock.should_receive(:debug).with('[Rollbar] Scheduling item')
113+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
114114

115115
request_data = {
116116
:params => { :foo => 'bar' }
@@ -156,12 +156,12 @@
156156
let(:logger_mock) { double('Rails.logger').as_null_object }
157157

158158
it 'should report exceptions without person or request data' do
159-
logger_mock.should_receive(:info).with('[Rollbar] Success')
159+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
160160
Rollbar.report_exception(@exception)
161161
end
162162

163163
it 'should not report anything when disabled' do
164-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
164+
logger_mock.should_not_receive(:debug).with('[Rollbar] Success')
165165
Rollbar.configure do |config|
166166
config.enabled = false
167167
end
@@ -196,7 +196,12 @@
196196
end
197197

198198
it 'should report exceptions with request and person data' do
199-
logger_mock.should_receive(:info).with('[Rollbar] Success')
199+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
200+
logger_mock.should_receive(:info).with(
201+
a_string_matching(
202+
/^\[Rollbar\] Details: \S+ \(only available if report was successful\)$/
203+
)
204+
).once
200205
request_data = {
201206
:params => { :foo => 'bar' },
202207
:url => 'http://localhost/',
@@ -217,7 +222,12 @@
217222
# Skip jruby 1.9+ (https://github.com/jruby/jruby/issues/2373)
218223
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && (RUBY_VERSION !~ /^1\.9/)
219224
it 'should work with an IO object as rack.errors' do
220-
logger_mock.should_receive(:info).with('[Rollbar] Success')
225+
logger_mock.should_receive(:debug).with('[Rollbar] Success')
226+
logger_mock.should_receive(:info).with(
227+
a_string_matching(
228+
/^\[Rollbar\] Details: \S+ \(only available if report was successful\)$/
229+
)
230+
).once
221231

222232
request_data = {
223233
:params => { :foo => 'bar' },
@@ -245,6 +255,7 @@
245255
config.exception_level_filters = { 'NameError' => 'ignore' }
246256
end
247257

258+
logger_mock.should_not_receive(:debug)
248259
logger_mock.should_not_receive(:info)
249260
logger_mock.should_not_receive(:error)
250261

@@ -256,6 +267,7 @@
256267
config.ignored_person_ids += [1]
257268
end
258269

270+
logger_mock.should_not_receive(:debug)
259271
logger_mock.should_not_receive(:info)
260272
logger_mock.should_not_receive(:error)
261273

@@ -302,7 +314,12 @@
302314
.with(@exception)
303315
.at_least(:once)
304316
.and_return('info')
305-
logger_mock.should_receive(:info)
317+
logger_mock.should_receive(:debug).with('[Rollbar] Success').once
318+
logger_mock.should_receive(:info).with(
319+
a_string_matching(
320+
/^\[Rollbar\] Details: \S+ \(only available if report was successful\)$/
321+
)
322+
).once
306323
logger_mock.should_not_receive(:error)
307324

308325
Rollbar.report_exception(@exception)

0 commit comments

Comments
 (0)