Exemplo n.º 1
0
 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']}");
     }
 }
Exemplo n.º 2
0
 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+');
 }
Exemplo n.º 3
0
 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');
     }
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 /**
  * 核心逻辑
  */
 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();
 }
Exemplo n.º 6
0
 public function __construct($msg, $argv = null)
 {
     parent::__construct($msg, $argv);
     Core_Log::fatal($msg, $argv);
 }
Exemplo n.º 7
0
 /**
  * * 运行完成后的回调
  * *
  * * 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)));
 }
Exemplo n.º 8
0
 /**
  * 执行实际的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;
 }