public static function handleFatalError() { if ($err = error_get_last()) { // 转换为相对路径,降低log 长度=。=! $err['file'] = str_replace(APPLICATION_PATH, '', $err['file']); Core_Log::getInstance()->error("{$err['message']} TYPE:{$err['type']} FILE:{$err['file']} LINE:{$err['line']}"); } }
public static function init($opt = array()) { self::$opt = array_merge(self::$opt, $opt); $filename = self::$opt['path'] . self::$opt['file']; if (is_dir(self::$opt['path']) == false) { mkdir(self::$opt['path'], 0755, true); } self::$nhd = fopen($filename, 'a+'); self::$whd = fopen($filename . '.wf', 'a+'); }
public function errorAction() { $exp = $this->getRequest()->getException(); $code = $exp->getCode(); if ($code === YAF_ERR_NOTFOUND_CONTROLLER || $code === YAF_ERR_NOTFOUND_ACTION) { Core_Log::warning($exp->getMessage()); header('HTTP/1.1 403 Forbidden'); } else { Core_Log::fatal($exp->getMessage()); header('HTTP/1.1 500 Internal Server Error'); } }
private function __uploadFile($filePath) { $paf = Arch_Paf::instance('image'); fwrite(fopen('d:/upload_1.log', 'w'), $filePath); $param = array('module' => 'image', 'file' => file_get_contents($filePath), 'size' => array(100)); $res = $paf->call('publish', $param); if ($res['flag'] == 0) { return $res['data']['100']; } fwrite(fopen('d:/upload_2.log', 'w'), serialize($res)); Core_Log::fatal('avatar upload fail', $res); return false; }
/** * 核心逻辑 */ public final function execute() { $this->ret['data'] = array(); try { $this->_init(); //初始化基本环境 $this->__prepare(); //针对下游的支持函数 $this->__before(); //针对执行之前的钩子,这个钩子提供个具体的框架通用逻辑使用,如用户登陆判断 权限验证等 $data = $this->__execute(); //实际执行业务逻辑,并返回数据的函数 empty($data) && ($data = array()); $this->ret['data'] = array_merge($this->ret['data'], $data); $this->__after(); //针对执行之后的钩子,这个钩子是提供给具体框架实现通用业务逻辑使用 $this->__complete(); //完成基本的收尾工作 $this->ret['flag'] = self::SUCC; } catch (Blue_Exception_Break $e) { //啥都不干 //只是用于跳出逻辑 } catch (Blue_Exception_Redirect $e) { $this->ret['redirect'] = $e->getUrl(); Core_Log::debug($e->getMessage(), $e->getArgv()); $this->ret['flag'] = self::SUCC; } catch (Blue_Exception_Fatal $e) { $this->ret['msg'] = 'system error'; $this->ret['flag'] = self::FAIL; $this->_message('系统错误'); } catch (Blue_Exception_Warning $e) { $this->ret['msg'] = $e->getMessage(); $this->ret['data'] = $e->getArgv(); $this->ret['flag'] = self::FAIL; $this->_message($e->getMessage()); } catch (Blue_Exception $e) { $this->ret['msg'] = 'system error'; $this->ret['flag'] = self::FAIL; $this->_message('系统错误'); //$this->ret['msg'] = $e->getMessage(); //$this->ret['data'] = $e->getArgv(); } //过滤掉NULL为空字符串 $this->_filterNullToString(); //输出 $this->_output(); }
public function __construct($msg, $argv = null) { parent::__construct($msg, $argv); Core_Log::fatal($msg, $argv); }
/** * * 运行完成后的回调 * * * * 1. log中增加 时间消耗、内存消耗 统计 * * 2. 输出日志 * */ public static function execShutdownCallback() { Core_Timer::endRecord(); Core_Log::debug('php status', array('cost' => Core_Timer::getResult(), 'mem' => memory_get_peak_usage(TRUE))); }
/** * 执行实际的SQL * * @param string $sql 执行的SQL语句 * * @return mixed */ public function query($sql) { $result = $this->ins->query($sql); Core_Log::debug("database query", array('sql' => $sql)); if ($result === FALSE) { throw new Blue_Exception_Fatal("DB Execute Error", array('msg' => $this->ins->error, 'errno' => $this->ins->errno, 'sql' => $sql)); } return $result; }