Bug 25172: Identify and display possible problems on the about page
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 16 Apr 2020 15:16:59 +0000 (17:16 +0200)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 22 Apr 2020 12:44:12 +0000 (13:44 +0100)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

about.pl
koha-tmpl/intranet-tmpl/prog/en/modules/about.tt

index dc25550..fc8dcec 100755 (executable)
--- a/about.pl
+++ b/about.pl
@@ -25,6 +25,7 @@ use Modern::Perl;
 use CGI qw ( -utf8 );
 use DateTime::TimeZone;
 use File::Spec;
+use File::Slurp;
 use List::MoreUtils qw/ any /;
 use LWP::Simple;
 use Module::Load::Conditional qw(can_load);
@@ -48,6 +49,7 @@ use Koha::Caches;
 use Koha::Config::SysPrefs;
 use Koha::Illrequest::Config;
 use Koha::SearchEngine::Elasticsearch;
+use Koha::Logger;
 
 use C4::Members::Statistics;
 
@@ -93,6 +95,24 @@ my $time_zone = {
     environment_invalid    => $env_invalid
 };
 
+{ # Logger checks
+    my $log4perl_config = C4::Context->config("log4perl_conf");
+    my @log4perl_errors;
+    if ( ! $log4perl_config ) {
+        push @log4perl_errors, 'missing_config_entry'
+    }
+    else {
+        my @lines = read_file($log4perl_config) or push @log4perl_errors, 'cannot_read_config_file';
+        for my $line ( @lines ) {
+            next unless $line =~ m|log4perl.appender.\w+.filename=(.*)|;
+            push @log4perl_errors, 'logfile_not_writable' unless -w $1;
+        }
+    }
+    eval {Koha::Logger->get};
+    push @log4perl_errors, 'cannot_init_module' and warn $@ if $@;
+    $template->param( log4perl_errors => @log4perl_errors );
+}
+
 $template->param(
     time_zone              => $time_zone,
     current_date_and_time  => output_pref({ dt => dt_from_string(), dateformat => 'iso' })
index d8f0dfa..d89910b 100644 (file)
         </div>
 
         <div id="sysinfo">
-    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships %]
+    [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues || oauth2_missing_deps || bad_yaml_prefs || warnRelationships || log4perl_errors %]
         [% IF (warnIsRootUser) %]
             <h2>Warning regarding current user</h2>
             <p>You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.</p>
             [% END %]
         [% END %]
 
+        [% IF log4perl_errors %]
+            <h2>Logging system does not behave correctly</h2>
+            [% FOR e IN log4perl_errors %]
+                [% SWITCH e %]
+                    [% CASE 'missing_config_entry' %]There is no 'log4perl_conf' entry in the config file.
+                    [% CASE 'cannot_read_config_file' %]The log4perl config file cannot be opened.
+                    [% CASE 'logfile_not_writable' %]One of the logfiles listed in the config file is not writable.
+                    [% CASE 'cannot_init_module' %]The Koha::Logger module cannot be initiated correctly (check the log file).
+                    [% CASE %]Unknown error "[% e %]"
+                [% END %]
+            [% END %]
+        [% END %]
+
         [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatronOPACPrivacy || warnPrefAnonymousPatronAnonSuggestions || warnPrefAnonymousPatronOPACPrivacy_PatronDoesNotExist || warnPrefAnonymousPatronAnonSuggestions_PatronDoesNotExist || warnNoActiveCurrency || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || oauth2_missing_deps || bad_yaml_prefs || warnIssuingRules %]
             <h2>Warnings regarding the system configuration</h2>
             <table>