Make Logger a little more robust by setting a default loglevel
authordbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 30 Oct 2007 22:26:11 +0000 (22:26 +0000)
committerdbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Tue, 30 Oct 2007 22:26:11 +0000 (22:26 +0000)
and ensuring that we don't try to regex an undefined value.

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1118 9efc2488-bf62-4759-914b-345cdb29e865

src/perlmods/OpenSRF/Utils/Logger.pm

index 8734115..7ee1eba 100644 (file)
@@ -1,4 +1,5 @@
 package OpenSRF::Utils::Logger;
+# vim:ts=4:noet:
 use strict;
 use vars qw($AUTOLOAD @EXPORT_OK %EXPORT_TAGS);
 use Exporter;
@@ -29,7 +30,7 @@ push @EXPORT_OK, '$logger';
 %EXPORT_TAGS = ( level => [ qw/ NONE ERROR WARN INFO DEBUG INTERNAL / ], logger => [ '$logger' ] );
 
 my $config;                                                    # config handle
-my $loglevel;                                          # global log level
+my $loglevel = INFO();                         # global log level
 my $logfile;                                           # log file
 my $facility;                                          # syslog facility
 my $actfac;                                                    # activity log syslog facility
@@ -101,8 +102,12 @@ sub set_config {
         $actfile = $config->bootstrap->actlog || $config->bootstrap->logfile;
     }
 
-
-       $isclient = (OpenSRF::Utils::Config->current->bootstrap->client =~ /^true$/iog) ?  1 : 0;
+       my $client = OpenSRF::Utils::Config->current->bootstrap->client();
+       if (!$client) {
+               $isclient = 0;
+               return;
+       }
+       $isclient = ($client =~ /^true$/iog) ?  1 : 0;
 }
 
 sub _fac_to_const {