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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
f7f30f4e
Commit
f7f30f4e
authored
Feb 14, 2014
by
Mark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added mail count filtering
parent
efea5711
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
20 deletions
+65
-20
LogTarget.php
extensions/debug/LogTarget.php
+30
-15
Debug.php
extensions/debug/models/search/Debug.php
+9
-3
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
+4
-0
No files found.
extensions/debug/LogTarget.php
View file @
f7f30f4e
...
...
@@ -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/models/search/Debug.php
View file @
f7f30f4e
...
...
@@ -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'
],
];
}
...
...
@@ -83,6 +87,7 @@ class Debug extends Base
'url'
=>
'url'
,
'statusCode'
=>
'Status code'
,
'sqlCount'
=>
'Total queries'
,
'mailCount'
=>
'Total mails'
,
];
}
...
...
@@ -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 @
f7f30f4e
...
...
@@ -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 @
f7f30f4e
...
...
@@ -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 @
f7f30f4e
...
...
@@ -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