[Koha-cvs] koha/C4 Output.pm [dev_week]
Mason James
szrj1m at yahoo.com
Fri Sep 21 06:47:47 CEST 2007
CVSROOT: /sources/koha
Module name: koha
Branch: dev_week
Changes by: Mason James <sushi> 07/09/21 04:47:47
Modified files:
C4 : Output.pm
Log message:
Koha Day - CGI::Carp execption handling wih 3 levels of info, set by DebugLevel syspref.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Output.pm?cvsroot=koha&only_with_tag=dev_week&r1=1.51.2.2.2.1&r2=1.51.2.2.2.2
Patches:
Index: Output.pm
===================================================================
RCS file: /sources/koha/koha/C4/Output.pm,v
retrieving revision 1.51.2.2.2.1
retrieving revision 1.51.2.2.2.2
diff -u -b -r1.51.2.2.2.1 -r1.51.2.2.2.2
--- Output.pm 3 Aug 2006 05:25:41 -0000 1.51.2.2.2.1
+++ Output.pm 21 Sep 2007 04:47:46 -0000 1.51.2.2.2.2
@@ -1,6 +1,6 @@
package C4::Output;
-# $Id: Output.pm,v 1.51.2.2.2.1 2006/08/03 05:25:41 kados Exp $
+# $Id: Output.pm,v 1.51.2.2.2.2 2007/09/21 04:47:46 sushi Exp $
#package to deal with marking up output
#You will need to edit parts of this pm
@@ -28,7 +28,40 @@
# templates.
use strict;
+
require Exporter;
+use CGI::Carp qw(fatalsToBrowser set_message);
+BEGIN {
+ 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";
+ }
+ }
+ set_message(\&handle_errors);
+}
+
use C4::Context;
use C4::Database;
@@ -51,9 +84,25 @@
@ISA = qw(Exporter);
@EXPORT = qw(
- &themelanguage &gettemplate setlanguagecookie
+ &themelanguage &gettemplate setlanguagecookie get_versions
);
+
+# 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;
+}
+
+
#FIXME: this is a quick fix to stop rc1 installing broken
#Still trying to figure out the correct fix.
my $path = C4::Context->config('intrahtdocs')."/default/en/includes/";
More information about the Koha-cvs
mailing list