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
940ac808
Commit
940ac808
authored
May 13, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
debugger tool WIP
parent
491e6608
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
68 deletions
+56
-68
DebugTarget.php
yii/logging/DebugTarget.php
+48
-0
Target.php
yii/logging/Target.php
+8
-7
WebTarget.php
yii/logging/WebTarget.php
+0
-61
No files found.
yii/logging/DebugTarget.php
0 → 100644
View file @
940ac808
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\logging
;
use
Yii
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
DebugTarget
extends
Target
{
/**
* Exports log messages to a specific destination.
* Child classes must implement this method.
* @param array $messages the messages to be exported. See [[Logger::messages]] for the structure
* of each message.
*/
public
function
export
(
$messages
)
{
}
/**
* Processes the given log messages.
* This method will filter the given messages with [[levels]] and [[categories]].
* And if requested, it will also export the filtering result to specific medium (e.g. email).
* @param array $messages log messages to be processed. See [[Logger::messages]] for the structure
* of each message.
* @param boolean $final whether this method is called at the end of the current application
*/
public
function
collect
(
$messages
,
$final
)
{
$this
->
messages
=
array_merge
(
$this
->
messages
,
$this
->
filterMessages
(
$messages
));
$count
=
count
(
$this
->
messages
);
if
(
$count
>
0
&&
(
$final
||
$this
->
exportInterval
>
0
&&
$count
>=
$this
->
exportInterval
))
{
if
((
$context
=
$this
->
getContextMessage
())
!==
''
)
{
$this
->
messages
[]
=
array
(
$context
,
Logger
::
LEVEL_INFO
,
'application'
,
YII_BEGIN_TIME
);
}
$this
->
export
(
$this
->
messages
);
$this
->
messages
=
array
();
}
}
}
yii/logging/Target.php
View file @
940ac808
...
...
@@ -7,6 +7,7 @@
namespace
yii\logging
;
use
yii\base\Component
;
use
yii\base\InvalidConfigException
;
/**
...
...
@@ -25,7 +26,7 @@ use yii\base\InvalidConfigException;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
abstract
class
Target
extends
\yii\base\
Component
abstract
class
Target
extends
Component
{
/**
* @var boolean whether to enable this log target. Defaults to true.
...
...
@@ -67,7 +68,7 @@ abstract class Target extends \yii\base\Component
/**
* @var array the messages that are retrieved from the logger so far by this log target.
*/
p
rivate
$_
messages
=
array
();
p
ublic
$
messages
=
array
();
private
$_levels
=
0
;
...
...
@@ -89,14 +90,14 @@ abstract class Target extends \yii\base\Component
*/
public
function
collect
(
$messages
,
$final
)
{
$this
->
_messages
=
array_merge
(
$this
->
_
messages
,
$this
->
filterMessages
(
$messages
));
$count
=
count
(
$this
->
_
messages
);
$this
->
messages
=
array_merge
(
$this
->
messages
,
$this
->
filterMessages
(
$messages
));
$count
=
count
(
$this
->
messages
);
if
(
$count
>
0
&&
(
$final
||
$this
->
exportInterval
>
0
&&
$count
>=
$this
->
exportInterval
))
{
if
((
$context
=
$this
->
getContextMessage
())
!==
''
)
{
$this
->
_
messages
[]
=
array
(
$context
,
Logger
::
LEVEL_INFO
,
'application'
,
YII_BEGIN_TIME
);
$this
->
messages
[]
=
array
(
$context
,
Logger
::
LEVEL_INFO
,
'application'
,
YII_BEGIN_TIME
);
}
$this
->
export
(
$this
->
_
messages
);
$this
->
_
messages
=
array
();
$this
->
export
(
$this
->
messages
);
$this
->
messages
=
array
();
}
}
...
...
yii/logging/WebTarget.php
deleted
100644 → 0
View file @
491e6608
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008-2011 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CWebLogRoute shows the log content in Web page.
*
* The log content can appear either at the end of the current Web page
* or in FireBug console window (if {@link showInFireBug} is set true).
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
CWebLogRoute
extends
CLogRoute
{
/**
* @var boolean whether the log should be displayed in FireBug instead of browser window. Defaults to false.
*/
public
$showInFireBug
=
false
;
/**
* @var boolean whether the log should be ignored in FireBug for ajax calls. Defaults to true.
* This option should be used carefully, because an ajax call returns all output as a result data.
* For example if the ajax call expects a json type result any output from the logger will cause ajax call to fail.
*/
public
$ignoreAjaxInFireBug
=
true
;
/**
* Displays the log messages.
* @param array $logs list of log messages
*/
public
function
processLogs
(
$logs
)
{
$this
->
render
(
'log'
,
$logs
);
}
/**
* Renders the view.
* @param string $view the view name (file name without extension). The file is assumed to be located under framework/data/views.
* @param array $data data to be passed to the view
*/
protected
function
render
(
$view
,
$data
)
{
$app
=
\Yii
::
$app
;
$isAjax
=
$app
->
getRequest
()
->
getIsAjaxRequest
();
if
(
$this
->
showInFireBug
)
{
if
(
$isAjax
&&
$this
->
ignoreAjaxInFireBug
)
return
;
$view
.=
'-firebug'
;
}
elseif
(
!
(
$app
instanceof
CWebApplication
)
||
$isAjax
)
return
;
$viewFile
=
YII_PATH
.
DIRECTORY_SEPARATOR
.
'views'
.
DIRECTORY_SEPARATOR
.
$view
.
'.php'
;
include
(
$app
->
findLocalizedFile
(
$viewFile
,
'en'
));
}
}
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