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

8
src/BaseService.php

@ -77,6 +77,11 @@ abstract class BaseService {
*/ */
public $config; public $config;
/**
* @var string 日志路径
*/
public $logFile = "/tmp/airpc-log";
/** /**
* @param string $listen 监听地址 * @param string $listen 监听地址
* @param integral $port 监听端口 * @param integral $port 监听端口
@ -89,7 +94,8 @@ abstract class BaseService {
'task_worker_num' => $this->taskWorkerNum, 'task_worker_num' => $this->taskWorkerNum,
'max_request' => $this->maxRequest, 'max_request' => $this->maxRequest,
'max_conn' => $this->maxConn, '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 * @author blobt
* Rpc协议 0.3 * Rpc协议 0.3
* struct
* {
* unisgned char type;
* unsigned int time;
* unisgned int serid;
* unsigned int length;
* char body[0];
* }
*/ */
class Pack { class Pack {

4
src/RpcServer.php

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

Loading…
Cancel
Save