2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
RSpec.describe Gitlab::AppLogger do
|
2018-03-17 18:26:18 +05:30
|
|
|
subject { described_class }
|
|
|
|
|
2023-01-13 00:05:48 +05:30
|
|
|
it 'builds two Logger instances' do
|
|
|
|
expect(Gitlab::Logger).to receive(:new).and_call_original
|
|
|
|
expect(Gitlab::JsonLogger).to receive(:new).and_call_original
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
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!')
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2020-10-24 23:57:45 +05:30
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|