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
5eac34a4
Commit
5eac34a4
authored
Jul 05, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debug toolbar WIP
parent
4ec95e6d
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
57 additions
and
12 deletions
+57
-12
LogPanel.php
framework/yii/debug/panels/LogPanel.php
+25
-1
RequestPanel.php
framework/yii/debug/panels/RequestPanel.php
+10
-2
StringHelper.php
framework/yii/helpers/base/StringHelper.php
+3
-0
Logger.php
framework/yii/log/Logger.php
+18
-0
Target.php
framework/yii/log/Target.php
+1
-9
No files found.
framework/yii/debug/panels/LogPanel.php
View file @
5eac34a4
...
...
@@ -9,6 +9,8 @@ namespace yii\debug\panels;
use
Yii
;
use
yii\debug\Panel
;
use
yii\helpers\Html
;
use
yii\log\Logger
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
...
...
@@ -33,7 +35,29 @@ EOD;
public
function
getDetail
()
{
return
'<h2>Logs</h2>'
;
$rows
=
array
();
foreach
(
$this
->
data
[
'messages'
]
as
$log
)
{
$time
=
date
(
'H:i:s.'
,
$log
[
3
])
.
sprintf
(
'%03d'
,
(
int
)((
$log
[
3
]
-
(
int
)
$log
[
3
])
*
1000
));
$level
=
Logger
::
getLevelName
(
$log
[
1
]);
$message
=
Html
::
encode
(
wordwrap
(
$log
[
0
]));
$rows
[]
=
"<tr><td style=
\"
width: 100px;
\"
>
$time
</td><td style=
\"
width: 100px;
\"
>
$level
</td><td style=
\"
width: 250px;
\"
>
{
$log
[
2
]
}
</td><td>
$message
</td></tr>"
;
}
$rows
=
implode
(
"
\n
"
,
$rows
);
return
<<<EOD
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead>
<tr>
<th style="width: 100px;">Time</th>
<th style="width: 100px;">Level</th>
<th style="width: 250px;">Category</th>
<th>Message</th>
</tr>
</thead>
<tbody>
$rows
</tbody>
</table>
EOD;
}
public
function
save
()
...
...
framework/yii/debug/panels/RequestPanel.php
View file @
5eac34a4
...
...
@@ -65,10 +65,18 @@ EOD;
{
$rows
=
array
();
foreach
(
$values
as
$name
=>
$value
)
{
$rows
[]
=
'<tr><th
>'
.
Html
::
encode
(
$name
)
.
'</th><td>'
.
Html
::
encode
(
var_export
(
$value
,
true
))
.
'
</td></tr>'
;
$rows
[]
=
'<tr><th
style="width: 200px;">'
.
Html
::
encode
(
$name
)
.
'</th><td><div style="overflow:auto">'
.
Html
::
encode
(
var_export
(
$value
,
true
))
.
'</div>
</td></tr>'
;
}
if
(
!
empty
(
$rows
))
{
return
"<table class=
\"
table table-condensed table-bordered table-hover
\"
>
\n
<thead>
\n
<tr><th>Name</th><th>Value</th></tr>
\n
</thead>
\n
<tbody>
\n
"
.
implode
(
"
\n
"
,
$rows
)
.
"
\n
</tbody>
\n
</table>"
;
$rows
=
implode
(
"
\n
"
,
$rows
);
return
<<<EOD
<table class="table table-condensed table-bordered table-striped table-hover" style="table-layout: fixed;">
<thead><tr><th style="width: 200px;">Name</th><th>Value</th></tr></thead>
<tbody>
$rows
</tbody>
</table>
EOD;
}
else
{
return
'Empty.'
;
}
...
...
framework/yii/helpers/base/StringHelper.php
View file @
5eac34a4
...
...
@@ -24,6 +24,9 @@ class StringHelper
*/
public
static
function
strlen
(
$string
)
{
if
(
!
function_exists
(
'mb_strlen'
))
{
throw
new
\Exception
(
'here'
);
}
return
mb_strlen
(
$string
,
'8bit'
);
}
...
...
framework/yii/log/Logger.php
View file @
5eac34a4
...
...
@@ -322,4 +322,22 @@ class Logger extends Component
return
$timings
;
}
/**
* Returns the text display of the specified level.
* @param integer $level the message level, e.g. [[LEVEL_ERROR]], [[LEVEL_WARNING]].
* @return string the text display of the level
*/
public
static
function
getLevelName
(
$level
)
{
static
$levels
=
array
(
self
::
LEVEL_ERROR
=>
'error'
,
self
::
LEVEL_WARNING
=>
'warning'
,
self
::
LEVEL_INFO
=>
'info'
,
self
::
LEVEL_TRACE
=>
'trace'
,
self
::
LEVEL_PROFILE_BEGIN
=>
'profile begin'
,
self
::
LEVEL_PROFILE_END
=>
'profile end'
,
);
return
isset
(
$levels
[
$level
])
?
$levels
[
$level
]
:
'unknown'
;
}
}
framework/yii/log/Target.php
View file @
5eac34a4
...
...
@@ -225,16 +225,8 @@ abstract class Target extends Component
*/
public
function
formatMessage
(
$message
)
{
static
$levels
=
array
(
Logger
::
LEVEL_ERROR
=>
'error'
,
Logger
::
LEVEL_WARNING
=>
'warning'
,
Logger
::
LEVEL_INFO
=>
'info'
,
Logger
::
LEVEL_TRACE
=>
'trace'
,
Logger
::
LEVEL_PROFILE_BEGIN
=>
'profile begin'
,
Logger
::
LEVEL_PROFILE_END
=>
'profile end'
,
);
list
(
$text
,
$level
,
$category
,
$timestamp
)
=
$message
;
$level
=
isset
(
$levels
[
$level
])
?
$levels
[
$level
]
:
'unknown'
;
$level
=
Logger
::
getLevelName
(
$level
)
;
if
(
!
is_string
(
$text
))
{
$text
=
var_export
(
$text
,
true
);
}
...
...
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