2019-07-25 01:21:37 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-10-19 02:41:55 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 05:08:32 -04:00
|
|
|
RSpec.describe Gitlab::AppLogger do
|
2017-10-19 02:41:55 -04:00
|
|
|
subject { described_class }
|
|
|
|
|
2020-01-13 16:07:39 -05:00
|
|
|
it 'builds a Gitlab::Logger object twice' do
|
|
|
|
expect(Gitlab::Logger).to receive(:new)
|
|
|
|
.exactly(described_class.loggers.size)
|
|
|
|
.and_call_original
|
2017-10-19 02:41:55 -04:00
|
|
|
|
2020-01-13 16:07:39 -05:00
|
|
|
subject.info('Hello World!')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'logs info to AppLogger and AppJsonLogger' do
|
|
|
|
expect_any_instance_of(Gitlab::AppTextLogger).to receive(:info).and_call_original
|
|
|
|
expect_any_instance_of(Gitlab::AppJsonLogger).to receive(:info).and_call_original
|
|
|
|
|
|
|
|
subject.info('Hello World!')
|
2017-10-19 02:41:55 -04:00
|
|
|
end
|
2020-08-13 17:10:04 -04:00
|
|
|
|
|
|
|
it 'logs info to only the AppJsonLogger when unstructured logs are disabled' do
|
|
|
|
stub_env('UNSTRUCTURED_RAILS_LOG', 'false')
|
|
|
|
expect_any_instance_of(Gitlab::AppTextLogger).not_to receive(:info).and_call_original
|
|
|
|
expect_any_instance_of(Gitlab::AppJsonLogger).to receive(:info).and_call_original
|
|
|
|
|
|
|
|
subject.info('Hello World!')
|
|
|
|
end
|
2017-10-19 02:41:55 -04:00
|
|
|
end
|