From 85a4c7b379ff8d90231e5b741238b38f28a8919b Mon Sep 17 00:00:00 2001 From: dbs Date: Fri, 13 Aug 2010 16:20:01 +0000 Subject: [PATCH] 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 git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1997 9efc2488-bf62-4759-914b-345cdb29e865 --- examples/opensrf_core.xml.example | 4 ++++ src/perl/lib/OpenSRF/Utils/Logger.pm | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/opensrf_core.xml.example b/examples/opensrf_core.xml.example index 3e307d3..a1f2498 100644 --- a/examples/opensrf_core.xml.example +++ b/examples/opensrf_core.xml.example @@ -56,6 +56,10 @@ vim:et:ts=2:sw=2: 3 + + 1536 + SYSCONFDIR/opensrf.xml diff --git a/src/perl/lib/OpenSRF/Utils/Logger.pm b/src/perl/lib/OpenSRF/Utils/Logger.pm index 76f1534..a524e35 100644 --- a/src/perl/lib/OpenSRF/Utils/Logger.pm +++ b/src/perl/lib/OpenSRF/Utils/Logger.pm @@ -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 ); } -- 2.43.2