Browse Source

add log

master
blobt 4 years ago
parent
commit
19cb164c2a
  1. 4
      examples/client.php
  2. 8
      src/BaseService.php
  3. 8
      src/Pack.php
  4. 4
      src/RpcServer.php

4
examples/client.php

@ -1,7 +1,6 @@
<?PHP
/**
* struct
* {
* unisgned char type;
* unsigned int time;
@ -52,5 +51,4 @@ $ret = remoteCall("127.0.0.1", "5188", '{"controller":"site","methor":"test","pa
//'{"controller":"site","methor":"test","params":{"id":1,"status":0}}'
echo "{$ret}\n";
?>
?>

8
src/BaseService.php

@ -76,6 +76,11 @@ abstract class BaseService {
* @var array swoole配置数组
*/
public $config;
/**
* @var string 日志路径
*/
public $logFile = "/tmp/airpc-log";
/**
* @param string $listen 监听地址
@ -89,7 +94,8 @@ abstract class BaseService {
'task_worker_num' => $this->taskWorkerNum,
'max_request' => $this->maxRequest,
'max_conn' => $this->maxConn,
'daemonize' => $this->daemonize
'daemonize' => $this->daemonize,
'log_file' => $this->logFile
];
}

8
src/Pack.php

@ -12,14 +12,6 @@ namespace blobt\airpc;
*
* @author blobt
* Rpc协议 0.3
* struct
* {
* unisgned char type;
* unsigned int time;
* unisgned int serid;
* unsigned int length;
* char body[0];
* }
*/
class Pack {

4
src/RpcServer.php

@ -63,11 +63,11 @@ class RpcServer extends BaseService {
$this->send($fd, $ret);
} catch (\Error $e) {
//TODO 记录日志
print_r($e);
echo "YeeError: ".$e->getMessage();
$this->send($fd, "YeeError");
} catch (\Exception $e) {
//TODO 记录日志
print_r($e);
echo "YeeException: ".$e->getMessage();
$this->send($fd, "YeeException");
}
}

Loading…
Cancel
Save