[Opensrf-commits] r1997 - in trunk: examples src/perl/lib/OpenSRF/Utils (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Fri Aug 13 12:20:04 EDT 2010


Author: dbs
Date: 2010-08-13 12:20:01 -0400 (Fri, 13 Aug 2010)
New Revision: 1997

Modified:
   trunk/examples/opensrf_core.xml.example
   trunk/src/perl/lib/OpenSRF/Utils/Logger.pm
Log:
Make log length in Perl logger a configurable value to assist debugging

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


Modified: trunk/examples/opensrf_core.xml.example
===================================================================
--- trunk/examples/opensrf_core.xml.example	2010-08-13 16:16:25 UTC (rev 1996)
+++ trunk/examples/opensrf_core.xml.example	2010-08-13 16:20:01 UTC (rev 1997)
@@ -56,6 +56,10 @@
     <!-- 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>
 

Modified: trunk/src/perl/lib/OpenSRF/Utils/Logger.pm
===================================================================
--- trunk/src/perl/lib/OpenSRF/Utils/Logger.pm	2010-08-13 16:16:25 UTC (rev 1996)
+++ trunk/src/perl/lib/OpenSRF/Utils/Logger.pm	2010-08-13 16:20:01 UTC (rev 1997)
@@ -40,6 +40,7 @@
 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 @@
 
 	$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 @@
 
 	$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 ); } 



More information about the opensrf-commits mailing list