Changeset 96 for trunk/include/xpress_debug_log.php
- Timestamp:
- Mar 6, 2009, 5:16:22 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/xpress_debug_log.php
r95 r96 57 57 } 58 58 } 59 60 function xpress_error_handler($errno,$errstr,$errfile,$errline,$errcontext) { 61 $module_dirpath = dirname(dirname(__FILE__)); 62 $root_path = dirname(dirname(dirname(dirname(__FILE__)))); 63 64 $show_backtrace = true; 65 66 // Time stamp of error entry 67 $dt = date("Y-m-d H:i:s (T)"); 68 69 // define an assoc array of error string 70 // in reality the only entries we should 71 // consider are E_WARNING, E_NOTICE, E_USER_ERROR, 72 // E_USER_WARNING and E_USER_NOTICE 73 $errortype = array ( 74 E_ERROR => "Error", 75 E_WARNING => "Warning", 76 E_PARSE => "Parsing Error", 77 E_NOTICE => "Notice", 78 E_CORE_ERROR => "Core Error", 79 E_CORE_WARNING => "Core Warning", 80 E_COMPILE_ERROR => "Compile Error", 81 E_COMPILE_WARNING => "Compile Warning", 82 E_USER_ERROR => "User Error", 83 E_USER_WARNING => "User Warning", 84 E_USER_NOTICE => "User Notice", 85 E_STRICT => "Runtime Notice" 86 ); 87 if (strstr($errstr, 'Use of undefined constant xpress_debug_message - assumed') !== false) return; 88 // set of errors for which a var trace will be saved 89 $user_errors = array(E_USER_ERROR, E_USER_WARNING, E_USER_NOTICE); 90 91 $err = "<errorentry>\n"; 92 $err .= "\t<datetime>" . $dt . "</datetime>\n"; 93 $err .= "\t<errornum>" . $errno . "</errornum>\n"; 94 $err .= "\t<errortype>" . $errortype[$errno] . "</errortype>\n"; 95 $err .= "\t<errormsg>" . $errstr . "</errormsg>\n"; 96 $err .= "\t<scriptname>" . $errfile . "</scriptname>\n"; 97 $err .= "\t<scriptlinenum>" . $errline . "</scriptlinenum>\n"; 98 $err .= "\t<errcontext>" . $errcontext . "</errcontext>\n"; 99 100 if (in_array($errno, $user_errors)) { 101 $err .= "\t<vartrace>" . wddx_serialize_value($vars, "Variables") . "</vartrace>\n"; 102 } 103 $err .= "</errorentry>\n\n"; 104 105 $err_trace = ''; 106 if ($show_backtrace){ 107 $backtraces = array_reverse(debug_backtrace()); 108 $err_trace .= "BACK TRACE\n"; 109 foreach($backtraces as $backtrace){ 110 $trace = @$backtrace['file']. "\tLINE(" . @$backtrace['line'] . ")\t" . @$backtrace['function'] . "()\n"; 111 $trace = str_replace($root_path,"",$trace); 112 $trace = str_replace("\\","/",$trace); 113 $trace = str_replace($root_path,"",$trace); 114 $trace = "\t" . $trace; 115 $err_trace .= $trace; 116 } 117 } 118 $head = "\n***** XPressME ERROR LOG ****************************************************************************************************\n"; 119 $message = $head . $err . $err_trace; 120 $_debug_file = $module_dirpath . '/wp-content/xpress_error.log'; 121 if ($errno != E_STRICT) { 122 $_fp = fopen($_debug_file, 'a'); 123 fwrite($_fp, $message); 124 fclose($_fp); 125 } 126 } 59 127 ?>
Note: See TracChangeset
for help on using the changeset viewer.