/[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.2 - (show annotations)
Sun Dec 1 04:47:19 2002 UTC (21 years, 8 months ago) by joko
Branch: MAIN
Changes since 1.1: +7 -2 lines
+ comments

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

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