Make log length in Perl logger a configurable value to assist debugging
authordbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 13 Aug 2010 16:20:01 +0000 (16:20 +0000)
committerdbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Fri, 13 Aug 2010 16:20:01 +0000 (16:20 +0000)
If logging to syslog instead of a file, you might need to adjust the
syslog configuration to accept longer than its own default lengths of
log messages

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

examples/opensrf_core.xml.example
src/perl/lib/OpenSRF/Utils/Logger.pm

index 3e307d3..a1f2498 100644 (file)
@@ -56,6 +56,10 @@ vim:et:ts=2:sw=2:
     <!-- 0 None, 1 Error, 2 Warning, 3 Info, 4 debug, 5 Internal (Nasty) -->
     <loglevel>3</loglevel>
 
+    <!-- Maximum log message length; if using syslog, you might need to adjust
+         your syslog service's configuration to match longer message lengths -->
+    <loglength>1536</loglength>
+
     <!-- config file for the services -->
     <settings_config>SYSCONFDIR/opensrf.xml</settings_config>
 
index 76f1534..a524e35 100644 (file)
@@ -40,6 +40,7 @@ my $syslog_enabled = 0;                       # is syslog enabled?
 my $act_syslog_enabled = 0;    # is syslog enabled?
 my $logfile_enabled = 1;               # are we logging to a file?
 my $act_logfile_enabled = 1;   # are we logging to a file?
+my $max_log_msg_len = 1536;                    # SYSLOG default maximum is 2048
 
 our $logger = "OpenSRF::Utils::Logger";
 
@@ -69,6 +70,10 @@ sub set_config {
 
        $loglevel =  $config->bootstrap->loglevel; 
 
+       if ($config->bootstrap->loglength) {
+               $max_log_msg_len = $config->bootstrap->loglength;
+       }
+
        $logfile = $config->bootstrap->logfile;
        if($logfile =~ /^syslog/) {
                $syslog_enabled = 1;
@@ -239,7 +244,8 @@ sub _log_message {
 
        $msg = "[$n:"."$$".":$file:$line_no:$osrf_xid] $msg";
 
-       $msg = substr($msg, 0, 1536); 
+       # Trim the message to the configured maximum log message length
+       $msg = substr($msg, 0, $max_log_msg_len); 
 
        if( $level == ACTIVITY() ) {
                if( is_act_syslog() ) { syslog( $fac | $l, $msg ); }