Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
one
提交
0c8da756
O
one
项目概览
OpenDocCN
/
one
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
one
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0c8da756
编写于
4月 04, 2019
作者:
lzc828
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
使用go问题
上级
afd18936
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
12 deletion
+21
-12
src/Facades/Log.php
src/Facades/Log.php
+1
-2
src/Http/Controller.php
src/Http/Controller.php
+5
-2
src/Log.php
src/Log.php
+4
-3
src/Swoole/TcpController.php
src/Swoole/TcpController.php
+5
-2
src/Swoole/WsController.php
src/Swoole/WsController.php
+6
-3
未找到文件。
src/Facades/Log.php
浏览文件 @
0c8da756
...
...
@@ -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
()
...
...
src/Http/Controller.php
浏览文件 @
0c8da756
...
...
@@ -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
);
}
/**
...
...
src/Log.php
浏览文件 @
0c8da756
...
...
@@ -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
]);
}
...
...
src/Swoole/TcpController.php
浏览文件 @
0c8da756
...
...
@@ -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
src/Swoole/WsController.php
浏览文件 @
0c8da756
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录