private static function getCheckResult() { $result = empty(self::$error); if (!$result) { $lang = get_lang('VALIDATE_PARAM_FAIL', json_encode(self::$userParams, JSON_UNESCAPED_UNICODE)); LoggerUtil::warn($lang); } return array('result' => $result, 'error' => self::$error, 'data' => self::$data); }
public function run($name, $args) { $lastSeparator = strrpos($name, '_'); $rpcArgs = array('service' => substr($name, 0, $lastSeparator), 'method' => substr($name, $lastSeparator + 1), 'params' => $args); try { LoggerUtil::info('RPC CALL: ' . json_encode($rpcArgs, JSON_UNESCAPED_UNICODE)); $serviceName = $this->getServiceName($rpcArgs['service'], false); $service = new $serviceName(); $methodName = $rpcArgs['method']; if (!method_exists($service, $methodName)) { throw new \Exception(get_lang('METHOD_NOT_FOUND', $methodName)); } $result = call_user_func_array(array($service, $methodName), $rpcArgs['params']); LoggerUtil::info('RPC SUCC: ' . json_encode($result, JSON_UNESCAPED_UNICODE)); return $result; } catch (\Exception $e) { LoggerUtil::error('RPC FAIL: ' . $e->getMessage()); return data_pack(get_code('REMOTE_RPC_FAIL'), $e->getMessage()); } }
/** * 记录上次执行sql */ public function logLastSql() { $sql = $this->getLastSql(); if (!empty($sql)) { LoggerUtil::info($sql); } }
/** * 错误输出 * @param mixed $error 错误 * @return void */ public static function halt($error) { if (class_exists('\\Common\\Library\\LoggerUtil')) { \Common\Library\LoggerUtil::error(is_array($error) ? $error['message'] : $error); } $e = array(); if (APP_DEBUG || IS_CLI) { //调试模式下输出错误信息 if (!is_array($error)) { $trace = debug_backtrace(); $e['message'] = $error; $e['file'] = $trace[0]['file']; $e['line'] = $trace[0]['line']; ob_start(); debug_print_backtrace(); $e['trace'] = ob_get_clean(); } else { $e = $error; } if (IS_CLI) { exit(iconv('UTF-8', 'gbk', $e['message']) . PHP_EOL . 'FILE: ' . $e['file'] . '(' . $e['line'] . ')' . PHP_EOL . $e['trace']); } } else { //否则定向到错误页面 $error_page = C('ERROR_PAGE'); if (!empty($error_page)) { redirect($error_page); } else { $message = is_array($error) ? $error['message'] : $error; $e['message'] = C('SHOW_ERROR_MSG') ? $message : C('ERROR_MESSAGE'); } } // 包含异常页面模板 $exceptionFile = C('TMPL_EXCEPTION_FILE', null, THINK_PATH . 'Tpl/think_exception.tpl'); include $exceptionFile; exit; }