Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
f198f655
Commit
f198f655
authored
Feb 14, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2438 from Ragazzo/debug_module_mail_improvements
Debug module mail improvements
parents
edb6bca1
5534b513
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
23 deletions
+69
-23
LogTarget.php
extensions/debug/LogTarget.php
+30
-15
Base.php
extensions/debug/components/search/matchers/Base.php
+2
-1
Debug.php
extensions/debug/models/search/Debug.php
+10
-4
DbPanel.php
extensions/debug/panels/DbPanel.php
+12
-2
MailPanel.php
extensions/debug/panels/MailPanel.php
+10
-0
index.php
extensions/debug/views/default/index.php
+5
-1
No files found.
extensions/debug/LogTarget.php
View file @
f198f655
...
...
@@ -47,19 +47,7 @@ class LogTarget extends Target
mkdir
(
$path
);
}
$request
=
Yii
::
$app
->
getRequest
();
$response
=
Yii
::
$app
->
getResponse
();
$summary
=
[
'tag'
=>
$this
->
tag
,
'url'
=>
$request
->
getAbsoluteUrl
(),
'ajax'
=>
$request
->
getIsAjax
(),
'method'
=>
$request
->
getMethod
(),
'ip'
=>
$request
->
getUserIP
(),
'time'
=>
time
(),
'statusCode'
=>
$response
->
statusCode
,
'sqlCount'
=>
$this
->
getSqlTotalCount
(),
];
$summary
=
$this
->
collectSummary
();
$dataFile
=
"
$path
/
{
$this
->
tag
}
.data"
;
$data
=
[];
foreach
(
$this
->
module
->
panels
as
$id
=>
$panel
)
{
...
...
@@ -140,6 +128,32 @@ class LogTarget extends Target
}
/**
* Collects summary data of current request.
* @return array
*/
protected
function
collectSummary
()
{
$request
=
Yii
::
$app
->
getRequest
();
$response
=
Yii
::
$app
->
getResponse
();
$summary
=
[
'tag'
=>
$this
->
tag
,
'url'
=>
$request
->
getAbsoluteUrl
(),
'ajax'
=>
$request
->
getIsAjax
(),
'method'
=>
$request
->
getMethod
(),
'ip'
=>
$request
->
getUserIP
(),
'time'
=>
time
(),
'statusCode'
=>
$response
->
statusCode
,
'sqlCount'
=>
$this
->
getSqlTotalCount
(),
];
if
(
isset
(
$this
->
module
->
panels
[
'mail'
]))
{
$summary
[
'mailCount'
]
=
count
(
$this
->
module
->
panels
[
'mail'
]
->
getMessages
());
}
return
$summary
;
}
/**
* Returns total sql count executed in current request. If database panel is not configured
* returns 0.
* @return integer
...
...
@@ -149,9 +163,10 @@ class LogTarget extends Target
if
(
!
isset
(
$this
->
module
->
panels
[
'db'
]))
{
return
0
;
}
$profileLogs
=
$this
->
module
->
panels
[
'db'
]
->
save
();
$profileLogs
=
$this
->
module
->
panels
[
'db'
]
->
getProfileLogs
();
# / 2 because messages are in couple (begin/end)
return
count
(
$profileLogs
[
'messages'
]
)
/
2
;
return
count
(
$profileLogs
)
/
2
;
}
}
extensions/debug/components/search/matchers/Base.php
View file @
f198f655
...
...
@@ -35,6 +35,7 @@ abstract class Base extends Component implements MatcherInterface
*/
public
function
hasValue
()
{
return
!
empty
(
$this
->
baseValue
)
||
$this
->
baseValue
===
0
;
return
!
empty
(
$this
->
baseValue
)
||
(
$this
->
baseValue
===
'0'
)
;
}
}
extensions/debug/models/search/Debug.php
View file @
f198f655
...
...
@@ -50,12 +50,16 @@ class Debug extends Base
public
$statusCode
;
/**
*
* @var integer sql count attribute input search value
*/
public
$sqlCount
;
/**
* @var integer total mail count attribute input search value
*/
public
$mailCount
;
/**
* @var array critical codes, used to determine grid row options.
*/
public
$criticalCodes
=
[
400
,
404
,
500
];
...
...
@@ -66,7 +70,7 @@ class Debug extends Base
public
function
rules
()
{
return
[
[[
'tag'
,
'ip'
,
'method'
,
'ajax'
,
'url'
,
'statusCode'
,
'sqlCount'
],
'safe'
],
[[
'tag'
,
'ip'
,
'method'
,
'ajax'
,
'url'
,
'statusCode'
,
'sqlCount'
,
'mailCount'
],
'safe'
],
];
}
...
...
@@ -82,7 +86,8 @@ class Debug extends Base
'ajax'
=>
'Ajax'
,
'url'
=>
'url'
,
'statusCode'
=>
'Status code'
,
'sqlCount'
=>
'Total queries'
,
'sqlCount'
=>
'Query Count'
,
'mailCount'
=>
'Mail Count'
,
];
}
...
...
@@ -97,7 +102,7 @@ class Debug extends Base
$dataProvider
=
new
ArrayDataProvider
([
'allModels'
=>
$models
,
'sort'
=>
[
'attributes'
=>
[
'method'
,
'ip'
,
'tag'
,
'time'
,
'statusCode'
,
'sqlCount'
],
'attributes'
=>
[
'method'
,
'ip'
,
'tag'
,
'time'
,
'statusCode'
,
'sqlCount'
,
'mailCount'
],
],
'pagination'
=>
[
'pageSize'
=>
50
,
...
...
@@ -116,6 +121,7 @@ class Debug extends Base
$this
->
addCondition
(
$filter
,
'url'
,
true
);
$this
->
addCondition
(
$filter
,
'statusCode'
);
$this
->
addCondition
(
$filter
,
'sqlCount'
);
$this
->
addCondition
(
$filter
,
'mailCount'
);
$dataProvider
->
allModels
=
$filter
->
filter
(
$models
);
return
$dataProvider
;
...
...
extensions/debug/panels/DbPanel.php
View file @
f198f655
...
...
@@ -94,9 +94,18 @@ class DbPanel extends Panel
*/
public
function
save
()
{
return
[
'messages'
=>
$this
->
getProfileLogs
()];
}
/**
* Returns all profile logs of the current request for this panel. It includes categories such as:
* 'yii\db\Command::query', 'yii\db\Command::execute'.
* @return array
*/
public
function
getProfileLogs
()
{
$target
=
$this
->
module
->
logTarget
;
$messages
=
$target
->
filterMessages
(
$target
->
messages
,
Logger
::
LEVEL_PROFILE
,
[
'yii\db\Command::query'
,
'yii\db\Command::execute'
]);
return
[
'messages'
=>
$messages
];
return
$target
->
filterMessages
(
$target
->
messages
,
Logger
::
LEVEL_PROFILE
,
[
'yii\db\Command::query'
,
'yii\db\Command::execute'
]);
}
/**
...
...
@@ -164,4 +173,5 @@ class DbPanel extends Panel
{
return
((
$this
->
criticalQueryThreshold
!==
null
)
&&
(
$count
>
$this
->
criticalQueryThreshold
));
}
}
extensions/debug/panels/MailPanel.php
View file @
f198f655
...
...
@@ -77,6 +77,16 @@ class MailPanel extends Panel
public
function
save
()
{
return
$this
->
getMessages
();
}
/**
* Returns info about messages of current request. Each element is array holding
* message info, such as: time, reply, bc, cc, from, to and other.
* @return array messages
*/
public
function
getMessages
()
{
return
$this
->
_messages
;
}
...
...
extensions/debug/views/default/index.php
View file @
f198f655
...
...
@@ -68,7 +68,7 @@ if (isset($this->context->module->panels['db']) && isset($this->context->module-
'ip'
,
[
'attribute'
=>
'sqlCount'
,
'label'
=>
'
Total queries
'
,
'label'
=>
'
Query Count
'
,
'value'
=>
function
(
$data
)
{
$dbPanel
=
$this
->
context
->
module
->
panels
[
'db'
];
...
...
@@ -86,6 +86,10 @@ if (isset($this->context->module->panels['db']) && isset($this->context->module-
'format'
=>
'html'
,
],
[
'attribute'
=>
'mailCount'
,
'visible'
=>
isset
(
$this
->
context
->
module
->
panels
[
'mail'
]),
],
[
'attribute'
=>
'method'
,
'filter'
=>
[
'get'
=>
'GET'
,
'post'
=>
'POST'
,
'delete'
=>
'DELETE'
,
'put'
=>
'PUT'
,
'head'
=>
'HEAD'
]
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment