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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations)
Fri Dec 13 09:19:32 2002 UTC (21 years, 8 months ago) by joko
Branch: MAIN
Changes since 1.2: +10 -1 lines
+ debugging

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

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