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
689e5d16
Commit
689e5d16
authored
Jul 02, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
renamed "logging" to "log".
parent
6033e200
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
84 additions
and
50 deletions
+84
-50
YiiBase.php
framework/yii/YiiBase.php
+7
-29
Application.php
framework/yii/base/Application.php
+12
-0
classes.php
framework/yii/classes.php
+6
-7
LogTarget.php
framework/yii/debug/LogTarget.php
+1
-1
DbTarget.php
framework/yii/log/DbTarget.php
+1
-1
EmailTarget.php
framework/yii/log/EmailTarget.php
+1
-1
FileTarget.php
framework/yii/log/FileTarget.php
+1
-1
Logger.php
framework/yii/log/Logger.php
+50
-5
Router.php
framework/yii/log/Router.php
+4
-4
Target.php
framework/yii/log/Target.php
+1
-1
No files found.
framework/yii/YiiBase.php
View file @
689e5d16
...
...
@@ -10,7 +10,7 @@ use yii\base\Exception;
use
yii\base\InvalidConfigException
;
use
yii\base\InvalidParamException
;
use
yii\base\UnknownClassException
;
use
yii\log
ging
\Logger
;
use
yii\log\Logger
;
/**
* Gets the application start timestamp.
...
...
@@ -478,7 +478,7 @@ class YiiBase
public
static
function
trace
(
$message
,
$category
=
'application'
)
{
if
(
YII_DEBUG
)
{
self
::
getLogger
()
->
log
(
$message
,
Logger
::
LEVEL_TRACE
,
$category
);
self
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_TRACE
,
$category
);
}
}
...
...
@@ -491,7 +491,7 @@ class YiiBase
*/
public
static
function
error
(
$message
,
$category
=
'application'
)
{
self
::
getLogger
()
->
log
(
$message
,
Logger
::
LEVEL_ERROR
,
$category
);
self
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_ERROR
,
$category
);
}
/**
...
...
@@ -503,7 +503,7 @@ class YiiBase
*/
public
static
function
warning
(
$message
,
$category
=
'application'
)
{
self
::
getLogger
()
->
log
(
$message
,
Logger
::
LEVEL_WARNING
,
$category
);
self
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_WARNING
,
$category
);
}
/**
...
...
@@ -515,7 +515,7 @@ class YiiBase
*/
public
static
function
info
(
$message
,
$category
=
'application'
)
{
self
::
getLogger
()
->
log
(
$message
,
Logger
::
LEVEL_INFO
,
$category
);
self
::
$app
->
getLog
()
->
log
(
$message
,
Logger
::
LEVEL_INFO
,
$category
);
}
/**
...
...
@@ -537,7 +537,7 @@ class YiiBase
*/
public
static
function
beginProfile
(
$token
,
$category
=
'application'
)
{
self
::
getLogger
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_BEGIN
,
$category
);
self
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_BEGIN
,
$category
);
}
/**
...
...
@@ -549,29 +549,7 @@ class YiiBase
*/
public
static
function
endProfile
(
$token
,
$category
=
'application'
)
{
self
::
getLogger
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_END
,
$category
);
}
/**
* Returns the message logger object.
* @return \yii\logging\Logger message logger
*/
public
static
function
getLogger
()
{
if
(
self
::
$_logger
!==
null
)
{
return
self
::
$_logger
;
}
else
{
return
self
::
$_logger
=
new
Logger
;
}
}
/**
* Sets the logger object.
* @param Logger $logger the logger object.
*/
public
static
function
setLogger
(
$logger
)
{
self
::
$_logger
=
$logger
;
self
::
$app
->
getLog
()
->
log
(
$token
,
Logger
::
LEVEL_PROFILE_END
,
$category
);
}
/**
...
...
framework/yii/base/Application.php
View file @
689e5d16
...
...
@@ -266,6 +266,15 @@ abstract class Application extends Module
}
/**
* Returns the log component.
* @return \yii\log\Logger the log component
*/
public
function
getLog
()
{
return
$this
->
getComponent
(
'log'
);
}
/**
* Returns the error handler component.
* @return ErrorHandler the error handler application component.
*/
...
...
@@ -344,6 +353,9 @@ abstract class Application extends Module
public
function
registerCoreComponents
()
{
$this
->
setComponents
(
array
(
'log'
=>
array
(
'class'
=>
'yii\log\Logger'
,
),
'errorHandler'
=>
array
(
'class'
=>
'yii\base\ErrorHandler'
,
),
...
...
framework/yii/classes.php
View file @
689e5d16
...
...
@@ -41,13 +41,12 @@ return array(
'yii\web\AssetBundle'
=>
YII_PATH
.
'/web/AssetBundle.php'
,
'yii\web\AssetConverter'
=>
YII_PATH
.
'/web/AssetConverter.php'
,
'yii\web\HeaderCollection'
=>
YII_PATH
.
'/web/HeaderCollection.php'
,
'yii\logging\Target'
=>
YII_PATH
.
'/logging/Target.php'
,
'yii\logging\DebugTarget'
=>
YII_PATH
.
'/logging/DebugTarget.php'
,
'yii\logging\Router'
=>
YII_PATH
.
'/logging/Router.php'
,
'yii\logging\Logger'
=>
YII_PATH
.
'/logging/Logger.php'
,
'yii\logging\EmailTarget'
=>
YII_PATH
.
'/logging/EmailTarget.php'
,
'yii\logging\DbTarget'
=>
YII_PATH
.
'/logging/DbTarget.php'
,
'yii\logging\FileTarget'
=>
YII_PATH
.
'/logging/FileTarget.php'
,
'yii\log\Target'
=>
YII_PATH
.
'/logging/Target.php'
,
'yii\log\DebugTarget'
=>
YII_PATH
.
'/logging/DebugTarget.php'
,
'yii\log\Logger'
=>
YII_PATH
.
'/logging/Logger.php'
,
'yii\log\EmailTarget'
=>
YII_PATH
.
'/logging/EmailTarget.php'
,
'yii\log\DbTarget'
=>
YII_PATH
.
'/logging/DbTarget.php'
,
'yii\log\FileTarget'
=>
YII_PATH
.
'/logging/FileTarget.php'
,
'yii\widgets\ActiveField'
=>
YII_PATH
.
'/widgets/ActiveField.php'
,
'yii\widgets\Captcha'
=>
YII_PATH
.
'/widgets/Captcha.php'
,
'yii\widgets\ListPager'
=>
YII_PATH
.
'/widgets/ListPager.php'
,
...
...
framework/yii/debug/LogTarget.php
View file @
689e5d16
...
...
@@ -8,7 +8,7 @@
namespace
yii\debug
;
use
Yii
;
use
yii\log
ging
\Target
;
use
yii\log\Target
;
/**
* @author Qiang Xue <qiang.xue@gmail.com>
...
...
framework/yii/log
ging
/DbTarget.php
→
framework/yii/log/DbTarget.php
View file @
689e5d16
...
...
@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
use
Yii
;
use
yii\db\Connection
;
...
...
framework/yii/log
ging
/EmailTarget.php
→
framework/yii/log/EmailTarget.php
View file @
689e5d16
...
...
@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
/**
* EmailTarget sends selected log messages to the specified email addresses.
...
...
framework/yii/log
ging
/FileTarget.php
→
framework/yii/log/FileTarget.php
View file @
689e5d16
...
...
@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
use
Yii
;
use
yii\base\InvalidConfigException
;
...
...
framework/yii/log
ging
/Logger.php
→
framework/yii/log/Logger.php
View file @
689e5d16
...
...
@@ -5,13 +5,57 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
use
\yii\base\Component
;
use
\yii\base\InvalidConfigException
;
/**
* Logger records logged messages in memory.
* Logger records logged messages in memory and sends them to different targets as needed.
*
* Logger is registered as a core application component and can be accessed using `Yii::$app->log`.
* You can call the method [[log()]] to record a single log message. For convenience, a set of shortcut
* methods are provided for logging messages of various severity levels via the [[Yii]] class:
*
* - [[Yii::trace()]]
* - [[Yii::error()]]
* - [[Yii::warning()]]
* - [[Yii::info()]]
* - [[Yii::beginProfile()]]
* - [[Yii::endProfile()]]
*
* When enough messages are accumulated in the logger, or when the current request finishes,
* the logged messages will be sent to different [[targets]], such as log files, emails.
*
* You may configure the targets in application configuration, like the following:
*
* ~~~
* array(
* 'components' => array(
* 'log' => array(
* 'targets' => array(
* 'file' => array(
* 'class' => 'yii\log\FileTarget',
* 'levels' => array('trace', 'info'),
* 'categories' => array('yii\*'),
* ),
* 'email' => array(
* 'class' => 'yii\log\EmailTarget',
* 'levels' => array('error', 'warning'),
* 'emails' => array('admin@example.com'),
* ),
* ),
* ),
* ),
* )
* ~~~
*
* Each log target can have a name and can be referenced via the [[targets]] property
* as follows:
*
* ~~~
* Yii::$app->log->targets['file']->enabled = false;
* ~~~
*
* When the application ends or [[flushInterval]] is reached, Logger will call [[flush()]]
* to send logged messages to different log targets, such as file, email, Web.
...
...
@@ -65,7 +109,7 @@ class Logger extends Component
*/
public
$flushInterval
=
1000
;
/**
* @var array logged messages. This property is ma
inly ma
naged by [[log()]] and [[flush()]].
* @var array logged messages. This property is managed by [[log()]] and [[flush()]].
* Each log message is of the following structure:
*
* ~~~
...
...
@@ -79,9 +123,10 @@ class Logger extends Component
*/
public
$messages
=
array
();
/**
* @var Router the log target router registered with this logger.
* @var array the log targets. Each array element represents a single [[Target|log target]] instance
* or the configuration for creating the log target instance.
*/
public
$
router
;
public
$
targets
=
array
()
;
/**
...
...
framework/yii/log
ging
/Router.php
→
framework/yii/log/Router.php
View file @
689e5d16
...
...
@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
use
Yii
;
use
yii\base\Component
;
...
...
@@ -27,15 +27,15 @@ use yii\base\Component;
* 'preload' => array('log'),
* 'components' => array(
* 'log' => array(
* 'class' => 'yii\log
ging
\Router',
* 'class' => 'yii\log\Router',
* 'targets' => array(
* 'file' => array(
* 'class' => 'yii\log
ging
\FileTarget',
* 'class' => 'yii\log\FileTarget',
* 'levels' => array('trace', 'info'),
* 'categories' => array('yii\*'),
* ),
* 'email' => array(
* 'class' => 'yii\log
ging
\EmailTarget',
* 'class' => 'yii\log\EmailTarget',
* 'levels' => array('error', 'warning'),
* 'emails' => array('admin@example.com'),
* ),
...
...
framework/yii/log
ging
/Target.php
→
framework/yii/log/Target.php
View file @
689e5d16
...
...
@@ -5,7 +5,7 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\log
ging
;
namespace
yii\log
;
use
Yii
;
use
yii\base\Component
;
...
...
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