koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] koha/C4 Context.pm [dev_week]


From: Mason James
Subject: [Koha-cvs] koha/C4 Context.pm [dev_week]
Date: Sat, 20 Oct 2007 02:57:22 +0000

CVSROOT:        /sources/koha
Module name:    koha
Branch:         dev_week
Changes by:     Mason James <sushi>     07/10/20 02:57:22

Modified files:
        C4             : Context.pm 

Log message:
        adding atz's new carp stuff to Context

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Context.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.18.2.5.2.15&r2=1.18.2.5.2.16

Patches:
Index: Context.pm
===================================================================
RCS file: /sources/koha/koha/C4/Context.pm,v
retrieving revision 1.18.2.5.2.15
retrieving revision 1.18.2.5.2.16
diff -u -b -r1.18.2.5.2.15 -r1.18.2.5.2.16
--- Context.pm  14 Jan 2007 22:40:26 -0000      1.18.2.5.2.15
+++ Context.pm  20 Oct 2007 02:57:22 -0000      1.18.2.5.2.16
@@ -16,8 +16,45 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: Context.pm,v 1.18.2.5.2.15 2007/01/14 22:40:26 rych Exp $
+# $Id: Context.pm,v 1.18.2.5.2.16 2007/10/20 02:57:22 sushi Exp $
 use strict;
+
+
+BEGIN {
+    if ($ENV{'USER_AGENT'}) {
+        require CGI::Carp;
+        import CGI::Carp qw(fatalsToBrowser);
+            sub handle_errors {
+                my $msg = shift;
+                my $debug_level =  C4::Context->preference("DebugLevel");
+
+                if ($debug_level eq "2"){
+                    # debug 2 , print extra info too.
+                    my %versions = get_versions();
+
+        # a little example table with various version info";
+                    print "
+                        <h1>debug level $debug_level </h1>
+                        <p>Got an error: $msg</p>
+                        <table>
+                        <tr><th>Apache<td>  $versions{apacheVersion}</tr>
+                        <tr><th>Koha<td>    $versions{kohaVersion}</tr>
+                        <tr><th>MySQL<td>   $versions{mysqlVersion}</tr>
+                        <tr><th>OS<td>      $versions{osVersion}</tr>
+                        <tr><th>Perl<td>    $versions{perlVersion}</tr>
+                        </table>";
+
+                } elsif ($debug_level eq "1"){
+                    print "<h1>debug level $debug_level </h1>";
+                    print "<p>Got an error: $msg</p>";
+                } else { 
+                    print "production mode - trapped fatal";
+                }       
+            }
+        CGI::Carp->set_message(\&handle_errors);
+    }   # else there is no browser to send fatals to!
+}
+
 use DBI;
 use ZOOM;
 use XML::Simple;
@@ -28,7 +65,7 @@
        qw($context),
        qw(@context_stack);
 
-$VERSION = do { my @v = '$Revision: 1.18.2.5.2.15 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.18.2.5.2.16 $' =~ /\d+/g;
                shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
@@ -816,6 +853,30 @@
        undef $context->{"activeuser"} if ($context->{"activeuser"} eq 
$sessionID);
 }
 
+=item get_versions
+
+  C4::Context->get_versions
+
+Gets various version info, for core Koha packages, Currently called from carp 
+handle_errors() sub, to send to browser if 'DebugLevel' syspref is set to '2'.
+
+=cut
+
+#'
+
+# A little example sub to show more debugging info for CGI::Carp
+sub get_versions {
+    my %versions;
+    $versions{kohaVersion}  = C4::Context->config("kohaversion");
+    $versions{osVersion} = `uname -a`;
+    $versions{perlVersion} = $];
+    $versions{mysqlVersion} = `mysql -V`; 
+    $versions{apacheVersion} =  `httpd -v`;
+    $versions{apacheVersion} =  `httpd2 -v`            unless  
$versions{apacheVersion} ;
+    $versions{apacheVersion} =  `apache2 -v`           unless  
$versions{apacheVersion} ;
+    $versions{apacheVersion} =  `/usr/sbin/apache2 -v` unless  
$versions{apacheVersion} ;
+    return %versions;
+}
 
 
 1;
@@ -843,6 +904,9 @@
 
 =cut
 # $Log: Context.pm,v $
+# Revision 1.18.2.5.2.16  2007/10/20 02:57:22  sushi
+# adding atz's new carp stuff to Context
+#
 # Revision 1.18.2.5.2.15  2007/01/14 22:40:26  rych
 # using zebra-dbname from config, change XMLIn forcearray
 #




reply via email to

[Prev in Thread] Current Thread [Next in Thread]