XPressME Integration Kit

Trac

source: trunk/include/xpress_debug_log.php @ 96

Last change on this file since 96 was 96, checked in by toemon, 15 years ago

途中経過でインストール、アップデートできなくなってしまっていたバグ修正
イベント通知の部分をFix、(ゲストのモジュールアクセス権限がないと通知できないのは直らない)
ブロックのキャッシュを見直し、キャッシュがない場合と、ブロックオプションが変更された場合にリフレッシュする機能を追加
ブロックキャッシュの更新にてポスト削除時のイベントをDB削除前にとっていたバグを修正。

File size: 4.6 KB
Line 
1<?php
2if (!function_exists('xpress_debug')) {
3        function xpress_debug($title = '',$ditail_show = false)
4        {
5                $module_dirpath = dirname(dirname(__FILE__));
6                $root_path = dirname(dirname(dirname(dirname(__FILE__))));
7                $_debug_file = $module_dirpath . '/wp-content/xpress_debug.log';
8                $_fp = fopen($_debug_file, 'a');
9                $stamp = date("Y/m/d G:i:s" , time());
10                $backtraces = array_reverse(debug_backtrace());
11                fwrite($_fp, "\n*********************************************************************************************************\n");
12                fwrite($_fp, $title . '(' . $stamp . ")\n");
13                fwrite($_fp, '$_SERVER[]' . "\n");     
14                $srerver = "\t" . str_replace("\n","\n\t",sprint_r($_SERVER));
15                fwrite($_fp, $srerver . "\n\n");
16
17                fwrite($_fp, "BACK TRACE" . "\n");     
18                foreach($backtraces as $backtrace){
19                $trace = $backtrace['file']. "\tLINE(" . $backtrace['line'] . ")\t" . $backtrace['function']  . "()\n";
20                $trace = str_replace($root_path,"",$trace);
21                $trace = str_replace("\\","/",$trace);
22                $trace = str_replace($root_path,"",$trace);
23                $trace = "\t" . $trace;
24
25                $trace_ditail = "\t" . str_replace("\n","\n\t\t",sprint_r($backtrace));
26                if ($ditail_show)
27                        fwrite($_fp, $trace . $trace_ditail . "\n");
28                else
29                        fwrite($_fp, $trace . "\n");
30                }
31                fclose($_fp);
32        }
33}
34
35if (!function_exists('xpress_debug_message')) {
36        function xpress_debug_message($message = '')
37        {
38                $module_dirpath = dirname(dirname(__FILE__));
39                $root_path = dirname(dirname(dirname(dirname(__FILE__))));
40                $_debug_file = $module_dirpath . '/wp-content/xpress_debug.log';
41                $_fp = fopen($_debug_file, 'a');
42                $stamp = date("Y/m/d G:i:s" , time());
43                fwrite($_fp, "\n*********************************************************************************************************\n");
44                fwrite($_fp, '(' . $stamp . ")\n");
45                fwrite($_fp, $message . "\n"); 
46                fclose($_fp);
47        }
48}
49
50if (!function_exists('sprint_r')) {
51    function sprint_r($var) {
52             ob_start();
53             print_r($var);
54             $ret = ob_get_contents();
55             ob_end_clean();
56      return $ret;
57    }
58}
59
60function 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}
127?>
Note: See TracBrowser for help on using the repository browser.