/** * 初始化 */ public function __construct() { $version = \H2O::getAppConfigs('version'); if (empty($version)) { throw new \Exception("Config set error: lost version param!"); } $nv = 'v' . str_replace('.', '', $version); $this->_migratedir = \H2O::getAppRootPath() . DS . 'migrate' . DS . $nv; $this->_namespace = \H2O::APP_ROOT_NAME . '\\migrate\\' . $nv; //命名空间 $this->_tpldir = H2O_PATH . DS . 'tpls' . DS . 'migrate' . DS; //迁移模块路径 file::createDirectory($this->_migratedir); //创建目录 $this->_runenv = \H2O::getRunEnv(); }
/** * 异常日志 * @param Exception $exception 异常信息 */ public function logException($exception) { $data = $this->parseException($exception); $logger = \H2O::getContainer('logger'); $env = \H2O::getRunEnv(); //获取运行环境 if ($env == 'prod') { //生产环境 $logger->exceptionWrite($data['message'], $data['files']); //写入错误日志 } else { //开发、测试环境 都直接显示错误 $logger->exceptionDebug($data['message'], $data['files']); //显示错误日志 方便调试 } if ($this->discardExistingOutput) { $this->clearOutput(); } }