コード例 #1
0
ファイル: auto.php プロジェクト: hiloy/autophp
    public static function shutdownCall()
    {
        if (self::$shutdownFunction) {
            call_user_func(self::$shutdownFunction);
            return;
        }
        if (!auto::isDebugMode()) {
            return;
        }
        //do not output debug info when ajax request
        if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
            return;
        }
        $rn = "\n";
        $hasNotRunPlugins = plugin::getHasNotRunPlugin(plugin::type_before_run);
        if ($hasNotRunPlugins) {
            $msg = array('title' => '<font color=red><b>Warning: some plugins NOT RUN(maybe "exit()" used! in your program?)</b></font>', 'msg' => var_export($hasNotRunPlugins, true));
            array_unshift(self::$_debugQueue, $msg);
        }
        $hasNotRunPlugins2 = plugin::getHasNotRunPlugin(plugin::type_after_run);
        if ($hasNotRunPlugins2) {
            $msg = array('title' => '<font color=red><b>Warning: some plugins NOT RUN(maybe "exit()" used in your program?)</b></font>', 'msg' => var_export($hasNotRunPlugins2, true));
            array_unshift(self::$_debugQueue, $msg);
        }
        //total cost
        auto::$runtimeEnd = microtime(true);
        $msg = array('title' => 'total runtime cost', 'msg' => auto::$runtimeEnd - auto::$runtimeStart);
        array_unshift(self::$_debugQueue, $msg);
        if (auto::isCliMode()) {
            $output = '
#################### debug info : ####################
(you can turn this off by "auto::setDebugMode(false)")
                ';
            foreach (self::$_debugQueue as $item) {
                $tstr = '
>>>>>>' . $item['title'] . '>>>>>> ' . $item['msg'];
                $output .= $tstr;
            }
            $output .= '
                ';
        } else {
            $output = '<style>.autophp_debug_span{width:100%;display:block;border-bottom: dashed 1px gray;margin: 3px 0 3px 0;padding:3px 0 3px 0;font-size: 14px;font-family: Arial}</style>
                <fieldset>
                <span  class="autophp_debug_span"><b>debug info : </b> (you can turn this off by "auto::setDebugMode(false)")</span>';
            foreach (self::$_debugQueue as $item) {
                $tstr = '<span class="autophp_debug_span"><font color=blue>' . $item['title'] . ': </font>' . $item['msg'] . '</span>';
                $output .= $tstr;
            }
            $output .= '</fieldset>';
        }
        echo $output;
    }