From: Stephen L Johnson Date: Wed, 9 Feb 2000 20:15:51 +0000 (+0000) Subject: added log() function to allow generic logging X-Git-Tag: spong-2_7-alpha5~85 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84c1e9ab4892fe8355324d18816fb8188525951f;p=spong.git added log() function to allow generic logging added trap routines for __DIE__ and __WARN__ to log die() and warn() output --- diff --git a/src/lib/Spong/Log.pm b/src/lib/Spong/Log.pm index d3ef7e9..ce1393c 100755 --- a/src/lib/Spong/Log.pm +++ b/src/lib/Spong/Log.pm @@ -32,6 +32,12 @@ my($errlog); &set_debug_context(); &set_error_context(); +# Setup intercept routines for die and warn in order to log their infomation +$main::SIG{'__DIE__'} = sub { if ( defined $^S && ! $^S && defined $errlog) + { $errlog->log("die(): " . $_[0]); } }; +$main::SIG{'__WARN__'} = sub { if ( defined $^S && ! $^S && defined $errlog) + { $errlog->log("warn(): " . $_[0]); } }; + # This function is used to set the debug logging context sub set_debug_context { @@ -80,13 +86,19 @@ sub close_error_log { undef $errlog; } -sub error { +sub log { my( $message ) = @_; # if the error logger is not defined, create it. if ( ! defined $errlog ) { &open_error_log(); } + + $errlog->log("$message"); +} + +sub error { + my( $message ) = @_; - $errlog->log("Error: $message"); + &log("Error: $message"); } sub debug {