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); } }