/[cvs]/nfo/php/libs/org.netfrag.flib/Application/ErrorHandler.php
ViewVC logotype

Contents of /nfo/php/libs/org.netfrag.flib/Application/ErrorHandler.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Sun Feb 9 17:30:27 2003 UTC (21 years, 5 months ago) by joko
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +5 -2 lines
+ minor update related to new log level constants

1 <?
2 // -------------------------------------------------------------------------
3 // $Id: ErrorHandler.php,v 1.3 2002/12/13 09:19:32 joko Exp $
4 // -------------------------------------------------------------------------
5 // $Log: ErrorHandler.php,v $
6 // Revision 1.3 2002/12/13 09:19:32 joko
7 // + debugging
8 //
9 // Revision 1.2 2002/12/01 04:47:19 joko
10 // + comments
11 //
12 // Revision 1.1 2002/11/12 05:42:30 joko
13 // + initial checkin
14 //
15 // -------------------------------------------------------------------------
16
17
18 // TODO: maybe use and/or enhance ErrorHandler from http://phpclasses.php-start.de/browse.html/package/345.html
19
20 function error_handler($level, $message, $file, $line, $context) {
21 global $Application_Error;
22 $Application_Error['this']->callErrorHandler($level, $message, $file, $line, $context);
23 }
24
25 class Application_ErrorHandler {
26
27 function Application_ErrorHandler(&$debugbox) {
28 $this->QUIET = 1;
29 $this->debugbox = $debugbox;
30 }
31
32 function activate($level = E_ALL) {
33 //return;
34 //print "1<br>";
35 //exit;
36 global $Application_Error;
37 //print "2<br>";
38 $Application_Error[this] = $this;
39 //print "3<br>";
40 //error_reporting($level);
41 error_reporting(E_ALL);
42 //print "4<br>";
43 set_error_handler('error_handler');
44 //print "5<br>";
45 }
46
47 function callErrorHandler($level, $message, $file, $line, $context) {
48
49 $phperror_type = array (
50 1 => "Error",
51 2 => "Warning",
52 4 => "Parsing Error",
53 8 => "Notice",
54 16 => "Core Error",
55 32 => "Core Warning",
56 64 => "Compile Error",
57 128 => "Compile Warning",
58 256 => "User Error",
59 512 => "User Warning",
60 1024=> "User Notice"
61 );
62
63 $level_text = $phperror_type[$level];
64
65 if ($level == E_USER_NOTICE) {
66 $phperror = $message;
67 } else {
68
69 $phperror = "
70 PHP-Error:
71 level: $level ($level_text)
72 file: $file
73 line: $line
74 The error message was: $message
75 ";
76 }
77
78 //The following variables were set in the scope that the error occurred in:
79 //" . dumpVar($context);
80
81 if ($this->debugbox) {
82 $this->debugbox->append($phperror, $level);
83 }
84
85 if (isset($this->site)) {
86
87 // logging mechanism
88 $this->site->log($phperror, PEAR_LOG_ERR);
89
90 // redirection to "STDOUT", make html for output
91 if ($this->site->config['mode']['PHPERRORS_LEVEL']) {
92 if ($level <= $this->site->config['mode']['PHPERRORS_LEVEL']) {
93 $phperror = str_replace("\n", "<br>", $phperror);
94 print $phperror;
95 }
96 }
97
98 } elseif (!$this->QUIET) {
99 $phperror = str_replace("\n", "<br>", $phperror);
100 print $phperror;
101 }
102
103 if ($level < E_ERROR) {
104 // TODO: logfile?
105 print $message . "<br>";
106 }
107
108 //print_r ($context);
109 //print "\n</blockquote>";
110 }
111
112 }
113
114 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed