/[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.1 - (show annotations)
Tue Nov 12 05:42:30 2002 UTC (21 years, 9 months ago) by joko
Branch: MAIN
+ initial checkin

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

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