public static function handler($exception) { if ($exception instanceof Exception) { $debugging = defined('IS_DEBUGGING') ? IS_DEBUGGING : false; $production = defined('IS_PRODUCTION') ? IS_PRODUCTION : false; if (true == $debugging) { if (true == $production) { ZOL_Log::write(ZOL_String::clean($exception), ZOL_Log::TYPE_EXCEPTION); } else { echo ZOL_Request::resolveType() == ZOL_Request::CLI ? ZOL_String::clean($exception) : $exception; } } else { header('location: ' . SYSTEM_HOMEPAGE); } } }
public static function handler($level, $errorMsg, $file, $line, $context = null) { if ('.tpl.php' == substr($file, -8)) { return; } $str = new ZOL_Exception($errorMsg, $level, $file, $line); $debugging = IS_DEBUGGING; $production = IS_PRODUCTION; if ($debugging) { $content = "<br />\n<h2>Error Info:</h2>\n" . '<b>MESSAGE:</b> ' . $errorMsg . "<br />\n" . '<b>TYPE:</b> ' . (isset(self::$levels[$level]) ? self::$levels[$level] : $level) . "<br />\n" . '<b>FILE:</b> ' . $file . "<br />\n" . '<b>LINE:</b> ' . $line . "<br />\n" . $str; if ($production) { ZOL_Log::write(ZOL_String::clean($content), ZOL_Log::TYPE_ERROR); } else { echo ZOL_Request::resolveType() == ZOL_Request::CLI ? ZOL_String::clean($content) : $content; } } }
/** * 获得注释 */ public function getSqlComment() { if (!$this->sqlComment) { $typeStr = "WEB"; $isCli = false; switch (ZOL_Request::resolveType()) { case ZOL_Request::CLI: $typeStr = "CLI"; $isCli = true; break; case ZOL_Request::AJAX: $typeStr = "AJAX"; break; case ZOL_Request::BROWSER: default: $typeStr = "WEB"; break; } if (ZOL_Registry::exists('request')) { $request = ZOL_Registry::get('request'); $c = $request->getControllerName(); $a = $request->getActionName(); } else { $c = $a = ""; if (!defined('APP_NAME')) { define("APP_NAME", ""); } } if ($isCli) { #如果是命令行执行 $this->sqlComment = "/*" . $_SERVER["HOSTNAME"] . ":{$typeStr}:" . APP_NAME . ":c={$c}&a={$a}*/"; } else { $this->sqlComment = "/*" . $_SERVER["HTTP_HOST"] . ":{$typeStr}:" . APP_NAME . ":c={$c}&a={$a}*/"; } } return $this->sqlComment; }