Browse Source

add log

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

2
examples/client.php

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

8
src/BaseService.php

@ -77,6 +77,11 @@ abstract class BaseService {
*/
public $config;
/**
* @var string 日志路径
*/
public $logFile = "/tmp/airpc-log";
/**
* @param string $listen 监听地址
* @param integral $port 监听端口
@ -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