From facc0a424f9586a30e766942d991910483803e61 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 20 Nov 2007 20:01:13 +0000 Subject: [PATCH] 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() git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1136 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perlmods/OpenSRF/EX.pm | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/perlmods/OpenSRF/EX.pm b/src/perlmods/OpenSRF/EX.pm index 8aff411..bf86bda 100644 --- a/src/perlmods/OpenSRF/EX.pm +++ b/src/perlmods/OpenSRF/EX.pm @@ -10,7 +10,7 @@ sub new { 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 throw() { 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 ); -- 2.11.0