提交 0c8da756 编写于 作者: lzc828's avatar lzc828

使用go问题

上级 afd18936
......@@ -12,11 +12,10 @@ namespace One\Facades;
* @method error($data, $k = 0, $prefix = 'error') static
* @method setTraceId($id) static
* @method bindTraceId($id) static
* @method flushTraceId() static
* @method flushTraceId($go_id) static
* @method getTraceId() static
*
*/
class Log extends Facade
{
protected static function getFacadeAccessor()
......
......@@ -4,6 +4,7 @@ namespace One\Http;
use One\Exceptions\HttpException;
use One\Facades\Log;
use SebastianBergmann\CodeCoverage\Report\PHP;
class Controller
{
......@@ -23,6 +24,8 @@ class Controller
*/
protected $server;
protected $go_id = -1;
/**
* Controller constructor.
......@@ -31,15 +34,15 @@ class Controller
*/
public function __construct($request, $response, $server = null)
{
$this->go_id = get_co_id();
$this->request = $request;
$this->response = $response;
$this->server = $server;
}
public function __destruct()
{
Log::flushTraceId();
Log::flushTraceId($this->go_id);
}
/**
......
......@@ -101,7 +101,9 @@ class Log
public function setTraceId($id)
{
$this->_traceId[get_co_id()] = $id;
$cid = get_co_id();
$this->_traceId[$cid] = $id;
return $cid;
}
/**
......@@ -132,10 +134,9 @@ class Log
/**
* 请求完成刷新 清除已经关闭的id
*/
public function flushTraceId()
public function flushTraceId($id)
{
if (_CLI_) {
$id = get_co_id();
if (isset($this->_traceId[$id])) {
unset($this->_traceId[$id]);
}
......
......@@ -28,10 +28,13 @@ class TcpController
*/
protected $session = null;
protected $go_id = -1;
public function __construct($data, $server)
{
$this->data = $data;
$this->go_id = get_co_id();
$this->data = $data;
$this->server = $server;
if ($this->data->session_id) {
$this->session = new Session(null, $this->data->session_id);
......@@ -40,7 +43,7 @@ class TcpController
public function __destruct()
{
Log::flushTraceId();
Log::flushTraceId($this->go_id);
}
}
\ No newline at end of file
......@@ -27,16 +27,19 @@ class WsController
*/
protected $session;
protected $go_id;
public function __construct($frame, $server, $session = null)
{
$this->frame = $frame;
$this->server = $server;
$this->go_id = get_co_id();
$this->frame = $frame;
$this->server = $server;
$this->session = $session;
}
public function __destruct()
{
Log::flushTraceId();
Log::flushTraceId($this->go_id);
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册