mirror of
https://github.com/yiisoft/yii2.git
synced 2025-08-26 06:15:19 +08:00
@ -50,6 +50,12 @@ use yii\base\Component;
|
|||||||
* Yii::$app->log->targets['file']->enabled = false;
|
* Yii::$app->log->targets['file']->enabled = false;
|
||||||
* ~~~
|
* ~~~
|
||||||
*
|
*
|
||||||
|
* @property integer $flushInterval How many messages should be logged before they are sent to targets. This
|
||||||
|
* method returns the value of [[Logger::flushInterval]].
|
||||||
|
* @property Logger $logger The logger. If not set, [[\Yii::getLogger()]] will be used.
|
||||||
|
* @property integer $traceLevel How many application call stacks should be logged together with each message.
|
||||||
|
* This method returns the value of [[Logger::traceLevel]]. Defaults to 0.
|
||||||
|
*
|
||||||
* @author Qiang Xue <qiang.xue@gmail.com>
|
* @author Qiang Xue <qiang.xue@gmail.com>
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
@ -61,9 +67,10 @@ class Dispatcher extends Component
|
|||||||
*/
|
*/
|
||||||
public $targets = [];
|
public $targets = [];
|
||||||
/**
|
/**
|
||||||
* @var Logger the logger. If not set, [[\Yii::getLogger()]] will be used.
|
* @var Logger the logger.
|
||||||
*/
|
*/
|
||||||
public $logger;
|
private $_logger;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes the logger by registering [[flush()]] as a shutdown function.
|
* Initializes the logger by registering [[flush()]] as a shutdown function.
|
||||||
@ -78,10 +85,32 @@ class Dispatcher extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->logger === null) {
|
// connect logger and dispatcher
|
||||||
$this->logger = Yii::getLogger();
|
$this->getLogger();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the connected logger.
|
||||||
|
* If not set, [[\Yii::getLogger()]] will be used.
|
||||||
|
* @property Logger the logger. If not set, [[\Yii::getLogger()]] will be used.
|
||||||
|
* @return Logger the logger.
|
||||||
|
*/
|
||||||
|
public function getLogger()
|
||||||
|
{
|
||||||
|
if ($this->_logger === null) {
|
||||||
|
$this->_logger = Yii::getLogger();
|
||||||
|
$this->_logger->dispatcher = $this;
|
||||||
}
|
}
|
||||||
$this->logger->dispatcher = $this;
|
return $this->_logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the connected logger.
|
||||||
|
* @param Logger $value the logger.
|
||||||
|
*/
|
||||||
|
public function setLogger($value)
|
||||||
|
{
|
||||||
|
$this->_logger = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,7 +119,7 @@ class Dispatcher extends Component
|
|||||||
*/
|
*/
|
||||||
public function getTraceLevel()
|
public function getTraceLevel()
|
||||||
{
|
{
|
||||||
return $this->logger->traceLevel;
|
return $this->getLogger()->traceLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -101,7 +130,7 @@ class Dispatcher extends Component
|
|||||||
*/
|
*/
|
||||||
public function setTraceLevel($value)
|
public function setTraceLevel($value)
|
||||||
{
|
{
|
||||||
$this->logger->traceLevel = $value;
|
$this->getLogger()->traceLevel = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,7 +139,7 @@ class Dispatcher extends Component
|
|||||||
*/
|
*/
|
||||||
public function getFlushInterval()
|
public function getFlushInterval()
|
||||||
{
|
{
|
||||||
return $this->logger->flushInterval;
|
return $this->getLogger()->flushInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -123,7 +152,7 @@ class Dispatcher extends Component
|
|||||||
*/
|
*/
|
||||||
public function setFlushInterval($value)
|
public function setFlushInterval($value)
|
||||||
{
|
{
|
||||||
$this->logger->flushInterval = $value;
|
$this->getLogger()->flushInterval = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -46,8 +46,8 @@ use yii\base\InvalidConfigException;
|
|||||||
*
|
*
|
||||||
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
|
* @property string|integer $id The unique identifier for the user. If null, it means the user is a guest.
|
||||||
* This property is read-only.
|
* This property is read-only.
|
||||||
* @property IdentityInterface $identity The identity object associated with the currently logged-in user.
|
* @property IdentityInterface|null $identity The identity object associated with the currently logged-in
|
||||||
* Null is returned if the user is not logged in (not authenticated).
|
* user. `null` is returned if the user is not logged in (not authenticated).
|
||||||
* @property boolean $isGuest Whether the current user is a guest. This property is read-only.
|
* @property boolean $isGuest Whether the current user is a guest. This property is read-only.
|
||||||
* @property string $returnUrl The URL that the user should be redirected to after login. Note that the type
|
* @property string $returnUrl The URL that the user should be redirected to after login. Note that the type
|
||||||
* of this property differs in getter and setter. See [[getReturnUrl()]] and [[setReturnUrl()]] for details.
|
* of this property differs in getter and setter. See [[getReturnUrl()]] and [[setReturnUrl()]] for details.
|
||||||
|
Reference in New Issue
Block a user