[Opensrf-commits] r1136 - trunk/src/perlmods/OpenSRF

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Nov 20 15:18:52 EST 2007


Author: erickson
Date: 2007-11-20 15:01:13 -0500 (Tue, 20 Nov 2007)
New Revision: 1136

Modified:
   trunk/src/perlmods/OpenSRF/EX.pm
Log:

Cleaned up exception messages so they will not be bloated with newlines 
(which are rendered as '\n' in syslog and local apache logs, anyway) and
layers of "Mess:" tags.  Logging the ISO timestamp instead of the default
output of Perl's localtime()




Modified: trunk/src/perlmods/OpenSRF/EX.pm
===================================================================
--- trunk/src/perlmods/OpenSRF/EX.pm	2007-11-20 20:00:53 UTC (rev 1135)
+++ trunk/src/perlmods/OpenSRF/EX.pm	2007-11-20 20:01:13 UTC (rev 1136)
@@ -10,7 +10,7 @@
 	my( $class, $message ) = @_;
 	$class = ref( $class ) || $class;
 	my $self = {};
-	$self->{'msg'} = ${$class . '::ex_msg_header'} ." \n$message";
+	$self->{'msg'} = ${$class . '::ex_msg_header'} .": $message";
 	return bless( $self, $class );
 }	
 
@@ -70,24 +70,25 @@
 
 
 sub stringify() {
-
 	my $self = shift;
-	my $ctime = localtime();
-	my( $package, $file, $line) = get_caller();
-	my $name = ref( $self );
+	my($package, $file, $line) = get_caller();
+	my $name = ref($self);
 	my $msg = $self->message();
 
-	$msg =~ s/^/Mess: /mg;
+    my ($sec,$min,$hour,$mday,$mon,$year) = localtime();
+    $year += 1900; $mon += 1;
+    my $date = sprintf(
+        '%s-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d',
+        $year, $mon, $mday, $hour, $min, $sec);
 
-	return "  * ! EXCEPTION ! * \nTYPE: $name\n$msg\n".
-		"Loc.: $line $package \nLoc.: $file \nTime: $ctime\n";
+    return "Exception: $name $date $package $file:$line $msg\n";
 }
 
 
 # --- determine the originating caller of this exception
 sub get_caller() {
 
-	$package = caller();
+	my $package = caller();
 	my $x = 0;
 	while( $package->isa( "Error" ) || $package =~ /^Error::/ ) { 
 		$package = caller( ++$x );



More information about the opensrf-commits mailing list