|
|
|
@ -82,11 +82,7 @@ class Logger extends Component
|
|
|
|
|
* @var Router the log target router registered with this logger. |
|
|
|
|
*/ |
|
|
|
|
public $router; |
|
|
|
|
/** |
|
|
|
|
* @var string a tag that uniquely identifies the current request. This can be used |
|
|
|
|
* to differentiate the log messages for different requests. |
|
|
|
|
*/ |
|
|
|
|
public $tag; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Initializes the logger by registering [[flush()]] as a shutdown function. |
|
|
|
@ -94,7 +90,6 @@ class Logger extends Component
|
|
|
|
|
public function init() |
|
|
|
|
{ |
|
|
|
|
parent::init(); |
|
|
|
|
$this->tag = date('Ymd-His', microtime(true)); |
|
|
|
|
register_shutdown_function(array($this, 'flush'), true); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -143,6 +138,25 @@ 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 |
|
|
|
|