From e900e53aa530ce15a73a4bf88cafa304999a99e9 Mon Sep 17 00:00:00 2001 From: Lukas Erlacher Date: Sat, 29 Oct 2016 17:10:41 +0200 Subject: [PATCH] Show log corresponding to env in admin/logs No matter which environment Gitlab was running as, the admin/logs view always showed production.log. This commit selects the logfile based on Rails.env. - Rename ProductionLogger to EnvironmentLogger - Make EnvironmentLogger logfile depend on env - Update spinach test for log tabs --- CHANGELOG.md | 1 + app/views/admin/logs/show.html.haml | 2 +- doc/administration/logs.md | 3 ++- features/steps/admin/logs.rb | 2 +- lib/gitlab/{production_logger.rb => environment_logger.rb} | 4 ++-- 5 files changed, 7 insertions(+), 5 deletions(-) rename lib/gitlab/{production_logger.rb => environment_logger.rb} (50%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7efa9efa4f8..64644453cfa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ entry. ## 8.14.0 (2016-11-22) +- Show correct environment log in admin/logs (@duk3luk3 !7191) - Fix Milestone dropdown not stay selected for `Upcoming` and `No Milestone` option !7117 - Backups do not fail anymore when using tar on annex and custom_hooks only. !5814 - Adds user project membership expired event to clarify why user was removed (Callum Dryden) diff --git a/app/views/admin/logs/show.html.haml b/app/views/admin/logs/show.html.haml index 676812121d7..824edd171f3 100644 --- a/app/views/admin/logs/show.html.haml +++ b/app/views/admin/logs/show.html.haml @@ -1,7 +1,7 @@ - @no_container = true - page_title "Logs" - loggers = [Gitlab::GitLogger, Gitlab::AppLogger, - Gitlab::ProductionLogger, Gitlab::SidekiqLogger, + Gitlab::EnvironmentLogger, Gitlab::SidekiqLogger, Gitlab::RepositoryCheckLogger] = render 'admin/background_jobs/head' diff --git a/doc/administration/logs.md b/doc/administration/logs.md index 737b39db16c..d757a3c2a66 100644 --- a/doc/administration/logs.md +++ b/doc/administration/logs.md @@ -13,7 +13,8 @@ This guide talks about how to read and use these system log files. This file lives in `/var/log/gitlab/gitlab-rails/production.log` for omnibus package or in `/home/git/gitlab/log/production.log` for -installations from source. +installations from source. (When Gitlab is running in an environment +other than production, the corresponding logfile is shown here.) It contains information about all performed requests. You can see the URL and type of request, IP address and what exactly parts of code were diff --git a/features/steps/admin/logs.rb b/features/steps/admin/logs.rb index f9e49588c75..63881d69146 100644 --- a/features/steps/admin/logs.rb +++ b/features/steps/admin/logs.rb @@ -4,7 +4,7 @@ class Spinach::Features::AdminLogs < Spinach::FeatureSteps include SharedAdmin step 'I should see tabs with available logs' do - expect(page).to have_content 'production.log' + expect(page).to have_content 'test.log' expect(page).to have_content 'githost.log' expect(page).to have_content 'application.log' end diff --git a/lib/gitlab/production_logger.rb b/lib/gitlab/environment_logger.rb similarity index 50% rename from lib/gitlab/production_logger.rb rename to lib/gitlab/environment_logger.rb index 89ce7144b1b..407cc572656 100644 --- a/lib/gitlab/production_logger.rb +++ b/lib/gitlab/environment_logger.rb @@ -1,7 +1,7 @@ module Gitlab - class ProductionLogger < Gitlab::Logger + class EnvironmentLogger < Gitlab::Logger def self.file_name_noext - 'production' + Rails.env end end end