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
840a84db
Commit
840a84db
authored
Jul 06, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debug toolbar refactoring.
parent
b6ffa7c9
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
15 additions
and
36 deletions
+15
-36
LogTarget.php
framework/yii/debug/LogTarget.php
+6
-5
Module.php
framework/yii/debug/Module.php
+2
-1
DefaultController.php
framework/yii/debug/controllers/DefaultController.php
+1
-0
ConfigPanel.php
framework/yii/debug/panels/ConfigPanel.php
+1
-4
toolbar.php
framework/yii/debug/views/default/toolbar.php
+5
-0
Logger.php
framework/yii/log/Logger.php
+0
-26
No files found.
framework/yii/debug/LogTarget.php
View file @
840a84db
...
...
@@ -20,12 +20,14 @@ class LogTarget extends Target
* @var Module
*/
public
$module
;
public
$maxLogFiles
=
20
;
public
$tag
;
public
$historySize
=
20
;
public
function
__construct
(
$module
,
$config
=
array
())
{
parent
::
__construct
(
$config
);
$this
->
module
=
$module
;
$this
->
tag
=
date
(
'Ymd-His'
,
microtime
(
true
));
}
/**
...
...
@@ -38,8 +40,7 @@ class LogTarget extends Target
if
(
!
is_dir
(
$path
))
{
mkdir
(
$path
);
}
$tag
=
Yii
::
$app
->
getLog
()
->
getTag
();
$file
=
"
$path
/
$tag
.log"
;
$file
=
"
$path
/
{
$this
->
tag
}
.log"
;
$data
=
array
();
foreach
(
$this
->
module
->
panels
as
$panel
)
{
$data
[
$panel
->
id
]
=
$panel
->
save
();
...
...
@@ -78,8 +79,8 @@ class LogTarget extends Target
}
}
sort
(
$files
);
if
(
count
(
$files
)
>
$this
->
maxLogFiles
)
{
$n
=
count
(
$files
)
-
$this
->
maxLogFiles
;
if
(
count
(
$files
)
>
$this
->
historySize
)
{
$n
=
count
(
$files
)
-
$this
->
historySize
;
foreach
(
$files
as
$i
=>
$file
)
{
if
(
$i
<
$n
)
{
unlink
(
$file
);
...
...
framework/yii/debug/Module.php
View file @
840a84db
...
...
@@ -63,8 +63,9 @@ class Module extends \yii\base\Module
{
/** @var View $view */
$id
=
'yii-debug-toolbar'
;
$tag
=
Yii
::
$app
->
getLog
()
->
targets
[
'debug'
]
->
tag
;
$url
=
Yii
::
$app
->
getUrlManager
()
->
createUrl
(
'debug/default/toolbar'
,
array
(
'tag'
=>
Yii
::
$app
->
getLog
()
->
getTag
()
,
'tag'
=>
$tag
,
));
$view
=
$event
->
sender
;
$view
->
registerJs
(
"yii.debug.load('
$id
', '
$url
');"
);
...
...
framework/yii/debug/controllers/DefaultController.php
View file @
840a84db
...
...
@@ -40,6 +40,7 @@ class DefaultController extends Controller
{
$this
->
loadData
(
$tag
);
return
$this
->
renderPartial
(
'toolbar'
,
array
(
'tag'
=>
$tag
,
'panels'
=>
$this
->
module
->
panels
,
));
}
...
...
framework/yii/debug/panels/ConfigPanel.php
View file @
840a84db
...
...
@@ -24,12 +24,10 @@ class ConfigPanel extends Panel
public
function
getSummary
()
{
$link
=
Html
::
a
(
'more details'
,
array
(
'index'
,
'tag'
=>
$this
->
data
[
'tag'
]));
return
<<<EOD
<div class="yii-debug-toolbar-block">
PHP: {$this->data['phpVersion']},
Yii: {$this->data['phpVersion']},
$link
Yii: {$this->data['phpVersion']}
</div>
EOD;
}
...
...
@@ -42,7 +40,6 @@ EOD;
public
function
save
()
{
return
array
(
'tag'
=>
Yii
::
$app
->
getLog
()
->
getTag
(),
'phpVersion'
=>
PHP_VERSION
,
'yiiVersion'
=>
Yii
::
getVersion
(),
);
...
...
framework/yii/debug/views/default/toolbar.php
View file @
840a84db
...
...
@@ -2,7 +2,9 @@
/**
* @var \yii\base\View $this
* @var \yii\debug\Panel[] $panels
* @var string $tag
*/
use
yii\helpers\Html
;
?>
<style>
#yii-debug-toolbar
{
...
...
@@ -28,4 +30,7 @@
<?php
foreach
(
$panels
as
$panel
)
:
?>
<?php
echo
$panel
->
getSummary
();
?>
<?php
endforeach
;
?>
<div
class=
"yii-debug-toolbar-block"
>
<?php
echo
Html
::
a
(
'more details'
,
array
(
'index'
,
'tag'
=>
$tag
));
?>
</div>
</div>
framework/yii/log/Logger.php
View file @
840a84db
...
...
@@ -129,13 +129,6 @@ class Logger extends Component
*/
public
$targets
=
array
();
/**
* @var string
*/
private
$_tag
;
/**
* Initializes the logger by registering [[flush()]] as a shutdown function.
*/
...
...
@@ -197,25 +190,6 @@ class Logger extends Component
}
/**
* @return string a tag that uniquely identifies the current request.
*/
public
function
getTag
()
{
if
(
$this
->
_tag
===
null
)
{
$this
->
_tag
=
date
(
'Ymd-His'
,
microtime
(
true
));
}
return
$this
->
_tag
;
}
/**
* @param string $tag a tag that uniquely identifies the current request.
*/
public
function
setTag
(
$tag
)
{
$this
->
_tag
=
$tag
;
}
/**
* Returns the total elapsed time since the start of the current request.
* This method calculates the difference between now and the timestamp
* defined by constant `YII_BEGIN_TIME` which is evaluated at the beginning
...
...
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