Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenDocCN
yii2_fecshop
提交
11eed2ed
Y
yii2_fecshop
项目概览
OpenDocCN
/
yii2_fecshop
通知
17
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
yii2_fecshop
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
11eed2ed
编写于
8月 22, 2017
作者:
T
Terry
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更改services中的log调用,更改为serviceLog component
上级
c58c21be
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
63 addition
and
35 deletion
+63
-35
components/ServiceLog.php
components/ServiceLog.php
+16
-19
config/components/ServiceLog.php
config/components/ServiceLog.php
+31
-0
config/services/Helper.php
config/services/Helper.php
+2
-0
services/Service.php
services/Service.php
+14
-16
未找到文件。
services/helper/
Log.php
→
components/Service
Log.php
浏览文件 @
11eed2ed
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
namespace
fecshop\
services\helper
;
namespace
fecshop\
components
;
use
fec\helpers\CRequest
;
//use fecshop\models\mongodb\FecshopServiceLog;
use
fecshop\services\Service
;
use
Yii
;
use
yii\base\BootstrapInterface
;
use
yii\base\Component
;
use
fec\helpers\CRequest
;
/**
* AR services.
* @author Terry Zhao <2358269014@qq.com>
* @since 1.0
*/
class
Log
extends
Service
class
ServiceLog
extends
Component
{
public
$log_config
;
protected
$_serviceContent
;
...
...
@@ -36,7 +34,7 @@ class Log extends Service
list
(
$this
->
_logModelName
,
$this
->
_logModel
)
=
Yii
::
mapGet
(
$this
->
_logModelName
);
}
/**
* Log
:g
et log uuid .
* Log
:g
et log uuid .
*/
public
function
getLogUid
()
{
...
...
@@ -48,7 +46,7 @@ class Log extends Service
}
/**
* ServiceLog
:是否开启ser
vice log.
* ServiceLog
:是否开启s
ervice log.
*/
public
function
isServiceLogEnable
()
{
...
...
@@ -67,7 +65,7 @@ class Log extends Service
}
/**
* ServiceLog
:保存se
rviceLog.
* ServiceLog
:保存s
erviceLog.
*/
public
function
printServiceLog
(
$log_info
)
{
...
...
@@ -79,12 +77,12 @@ class Log extends Service
foreach
(
$log_info
as
$k
=>
$v
)
{
if
(
is_array
(
$v
))
{
$v
=
implode
(
'<br>'
,
$v
);
$str
.
=
"<tr>
<td>
$k
</td><td>
$v
</td>
$str
.
=
"<tr>
<td>
$k
</td><td>
$v
</td>
</tr>"
;
}
else
{
$str
.
=
"<tr>
<td>
$k
</td><td>
$v
</td>
$str
.
=
"<tr>
<td>
$k
</td><td>
$v
</td>
</tr>"
;
}
}
...
...
@@ -94,7 +92,7 @@ class Log extends Service
}
/**
* ServiceLog
:i
f service log db print is enable.
* ServiceLog
:i
f service log db print is enable.
*/
protected
function
isServiceLogDbPrint
()
{
...
...
@@ -115,7 +113,7 @@ class Log extends Service
}
/**
* ServiceLog
:在前台打印servicelog是否开启.
* ServiceLog
:在前台打印servicelog是否开启
.
*/
protected
function
isServiceLogHtmlPrint
()
{
...
...
@@ -136,7 +134,7 @@ class Log extends Service
}
/**
* ServiceLog
:通过参数,在前台打印servicelog是否开启.
* ServiceLog
:通过参数,在前台打印servicelog是否开启
.
*/
protected
function
isServiceLogDbPrintByParam
()
{
...
...
@@ -180,8 +178,7 @@ class Log extends Service
.
substr
(
$charid
,
16
,
4
)
.
$hyphen
.
substr
(
$charid
,
20
,
12
)
//.chr(125)// "}"
;
;
return
$uuid
;
}
}
...
...
config/components/ServiceLog.php
0 → 100644
浏览文件 @
11eed2ed
<?php
/**
* FecShop file.
*
* @link http://www.fecshop.com/
* @copyright Copyright (c) 2016 FecShop Software LLC
* @license http://www.fecshop.com/license/
*/
return
[
'serviceLog'
=>
[
'class'
=>
'fecshop\components\ServiceLog'
,
'log_config'
=>
[
// service log config
'services'
=>
[
// if enable is false , all services will be close
'enable'
=>
false
,
// print log info to db.
'dbprint'
=>
false
,
// print log info to front html
'htmlprint'
=>
false
,
// print log
'htmlprintbyparam'
=>
[
// like :http://fecshop.appfront.fancyecommerce.com/cn/?servicelog=xxxxxxxx
'enable'
=>
false
,
'paramKey'
=>
'servicelog'
,
'paramVal'
=>
'xxxxxxxx'
,
],
],
],
],
];
\ No newline at end of file
config/services/Helper.php
浏览文件 @
11eed2ed
...
...
@@ -13,6 +13,7 @@ return [
'ar'
=>
[
'class'
=>
'fecshop\services\helper\AR'
,
],
/* 已经废除,现在使用Yii::$app->serviceLog
'log' => [
'class' => 'fecshop\services\helper\Log',
'log_config' => [
...
...
@@ -34,6 +35,7 @@ return [
],
],
],
*/
'errors'
=>
[
'class'
=>
'fecshop\services\helper\Errors'
,
],
...
...
services/Service.php
浏览文件 @
11eed2ed
...
...
@@ -103,7 +103,7 @@ class Service extends Object
*/
protected
function
beginCall
(
$originMethod
,
$arguments
)
{
if
(
Yii
::
$
service
->
helper
->
l
og
->
isServiceLogEnable
())
{
if
(
Yii
::
$
app
->
serviceL
og
->
isServiceLogEnable
())
{
$this
->
_beginCallTime
=
microtime
(
true
);
}
}
...
...
@@ -116,7 +116,7 @@ class Service extends Object
*/
protected
function
endCall
(
$originMethod
,
$arguments
)
{
if
(
Yii
::
$
service
->
helper
->
l
og
->
isServiceLogEnable
())
{
if
(
Yii
::
$
app
->
serviceL
og
->
isServiceLogEnable
())
{
list
(
$logTrace
,
$isCalledByThis
)
=
$this
->
debugBackTrace
();
/*
* if function is called by $this ,not log it to mongodb.
...
...
@@ -134,24 +134,22 @@ class Service extends Object
}
else
{
$arguments
=
'string or int or other'
;
}
$serviceLogUid
=
Yii
::
$
service
->
helper
->
l
og
->
getLogUid
();
$serviceLogUid
=
Yii
::
$
app
->
serviceL
og
->
getLogUid
();
$log_info
=
[
'service_uid'
=>
$serviceLogUid
,
'current_url'
=>
Yii
::
$service
->
url
->
getCurrentUrl
(),
'home_url'
=>
Yii
::
$service
->
url
->
homeUrl
(),
'service_file'
=>
get_class
(
$this
),
'service_uid'
=>
$serviceLogUid
,
'current_url'
=>
Yii
::
$service
->
url
->
getCurrentUrl
(),
'home_url'
=>
Yii
::
$service
->
url
->
homeUrl
(),
'service_file'
=>
get_class
(
$this
),
'service_method'
=>
$originMethod
,
'service_method_argument'
=>
$arguments
,
'begin_microtime'
=>
$begin_microtime
,
'end_microtime'
=>
$endCallTime
,
'used_time'
=>
$used_time
,
'process_date_time'
=>
date
(
'Y-m-d H:i:s'
),
'log_trace'
=>
$logTrace
,
'service_method_argument'
=>
$arguments
,
'begin_microtime'
=>
$begin_microtime
,
'end_microtime'
=>
$endCallTime
,
'used_time'
=>
$used_time
,
'process_date_time'
=>
date
(
'Y-m-d H:i:s'
),
'log_trace'
=>
$logTrace
,
];
//Yii::$service->helper->log->fetchServiceLog($log_info);
Yii
::
$service
->
helper
->
log
->
printServiceLog
(
$log_info
);
Yii
::
$app
->
serviceLog
->
printServiceLog
(
$log_info
);
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录