/[cvs]/nfo/php/libs/org.netfrag.glib/php_errors.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.glib/php_errors.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Fri Apr 4 17:34:17 2003 UTC (21 years, 4 months ago) by joko
Branch: MAIN
initial commit

1 joko 1.1 <?php
2    
3     /**
4     * This file contains some core functions extending php,
5     * especially regarding basic error handling.
6     *
7     * @author Andreas Motl <andreas.motl@ilo.de>
8     * @package org.netfrag.glib
9     * @name errors
10     *
11     */
12    
13     /**
14     * $Id: php_constants.php,v 1.1 2003/03/28 06:43:20 joko Exp $
15     *
16     * $Log: php_constants.php,v $
17     *
18     */
19    
20    
21     /**
22     * --- functions supporting handling errors/exceptions
23     *
24     */
25    
26    
27     /**
28     * --- php error extension functions living in the global namespace
29     *
30     *
31     * @author Andreas Motl <andreas.motl@ilo.de>
32     * @copyright (c) 2003 - All Rights reserved.
33     * @license GNU LGPL (GNU Lesser General Public License)
34     *
35     * @link http://www.netfrag.org/~joko/
36     * @link http://www.gnu.org/licenses/lgpl.txt
37     *
38     * @package org.netfrag.glib
39     * @name errors
40     *
41     *
42     */
43    
44     //function error_handler($errno, $errstr, $errfile, $errline) {
45     function php_error_handler() {
46    
47     // build error hash
48     $error_raw = func_get_args();
49     $error = array(
50     'level' => $error_raw[0],
51     'message' => $error_raw[1],
52     'file' => $error_raw[2],
53     'line' => $error_raw[3],
54     'context' => &$error_raw[4],
55     'object_context' => &$error_raw[4][this],
56     );
57     $error[component] = $error[object_context]->_component_name;
58    
59    
60     // component errors / stack-backtrace
61    
62     /*
63     $level = $error[0];
64     $context = &$error[4];
65     $cc = &$context['this'];
66     */
67    
68     // tracing
69     //print Dumper($context);
70     //print Dumper($cc);
71     //print Dumper($cc->_component_name);
72    
73     // by level
74     //$do_trace = ($level <= 5);
75    
76     //$c_name = $context['this']['_component_name'];
77    
78     //print "c_error: $c_name<br/>";
79    
80     // if component
81     //$do_trace = isset($context[this][_component_name]);
82     //$do_trace = isset($context->this[_component_name]);
83     //$do_trace = isset($cc->_component_name);
84    
85     //print Dumper($context);
86    
87    
88    
89     // V0 - testing (always on)
90     //$do_trace = 1;
91    
92     // V1 - just for components
93     //$do_trace = isset($error[component]);
94    
95     // V2 - actions via constant definition(s)
96     $do_render = !constants::get('PHP_ERRORS_DISABLED') && constants::get('PHP_ERRORS_ENABLED');
97     $do_verbose = constants::get('PHP_ERRORS_MODE_VERBOSE');
98     $do_trace = constants::get('PHP_ERRORS_MODE_TRACE');
99     // ignore debugging-messages here if not explicitely requested
100     if (!constants::get('PHP_ERRORS_TRACE_LEVEL_DEBUG')) {
101     $do_verbose = $do_verbose && ($error[level] != 8);
102     $do_trace = $do_trace && ($error[level] != 8);
103     }
104    
105    
106     // Rendering
107    
108     if ($do_render) {
109    
110     // which box to draw?
111    
112     // V1 - fixed set of error attributes
113     //$output_order = array( 'message', 'component', 'file', 'line', 'level' );
114     //$output_order = array( 'message', 'level', 'file', 'line' );
115    
116     // V2 - build variable set dependent on defined constant(s)
117     $output_order = array();
118     $box_type = constants::get('PHP_ERRORS_BOX_TYPE');
119     //print "boxtype: $box_type<br/>";
120     switch ($box_type) {
121     case 'full':
122     $output_order = array( 'message', 'component', 'file', 'line', 'level' );
123     break;
124     case 'medium':
125     $output_order = array( 'message', 'level', 'file', 'line' );
126     break;
127     default:
128     $output_order = array( 'message', 'level' );
129     break;
130     }
131    
132     //print php::Dumper($error);
133     //exit;
134    
135     // dispatch color by level
136     if ($error[level] <= 8) {
137     $color = '#eeeeee';
138     } elseif ($error[level] == 512) {
139     $color = 'orange';
140     } elseif ($error[level] == 1024) {
141     $color = 'yellow';
142     }
143    
144     ob_start();
145     //print "<hr/><b><font color=\"red\">ERROR:</font></b><br/>";
146     print "<div style=\"background:$color; margin:4px; border:1px black groove; padding:2px;\"><b><font color=\"red\">Event:</font></b> [ErrorCode: $error[level]]<br/> ";
147     foreach ($output_order as $key) {
148     print "<b>$key:</b> $error[$key]<br/>";
149     }
150     print "</div>\n";
151     $out = ob_get_contents();
152     ob_end_clean();
153    
154     if ($do_trace) {
155     if (loadModule('Tracer')) {
156     trace($out);
157     }
158     }
159    
160     if ($do_verbose) {
161     print $out;
162     }
163    
164     }
165    
166     }
167    
168    
169     ?>

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