diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 03:14:16 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-09 03:14:16 +0300 |
commit | 9922b38ff03500d311dd7de771961154f50ea8f4 (patch) | |
tree | ff7919d2b88c17be4d6c56db21a34ae3f90d1636 /spec/lib | |
parent | 0cb58c941627c8237e65a67e83aa9ff8b59109ae (diff) |
Add latest changes from gitlab-org/gitlab@15-11-stable-ee
Diffstat (limited to 'spec/lib')
-rw-r--r-- | spec/lib/gitlab/app_logger_spec.rb | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/spec/lib/gitlab/app_logger_spec.rb b/spec/lib/gitlab/app_logger_spec.rb index 149c3d1f19f..4eb0d628291 100644 --- a/spec/lib/gitlab/app_logger_spec.rb +++ b/spec/lib/gitlab/app_logger_spec.rb @@ -7,9 +7,32 @@ RSpec.describe Gitlab::AppLogger, feature_category: :shared do specify { expect(described_class.primary_logger).to be Gitlab::AppJsonLogger } - it 'logs to AppJsonLogger' do - expect_any_instance_of(Gitlab::AppJsonLogger).to receive(:info).and_call_original + context 'when UNSTRUCTURED_RAILS_LOG is enabled' do + before do + stub_env('UNSTRUCTURED_RAILS_LOG', 'true') + end - subject.info('Hello World!') + it 'builds two Logger instances' do + expect(Gitlab::Logger).to receive(:new).and_call_original + expect(Gitlab::JsonLogger).to receive(:new).and_call_original + + subject.info('Hello World!') + end + + it 'logs info to multiple loggers' 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!') + end + end + + context 'when UNSTRUCTURED_RAILS_LOG is disabled' do + it 'logs info to only the AppJsonLogger' do + 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 end end |