* @param string $value directory for storing log files.
* @throws CException if the path is invalid
*/
public function setLogPath($value)
{
$this->_logPath = realpath($value);
if ($this->_logPath === false || !is_dir($this->_logPath) || !is_writable($this->_logPath))
throw new CException(Yii::t('yii', 'CFileLogRoute.logPath "{path}" does not point to a valid directory. Make sure the directory exists and is writable by the Web server process.',
array('{path}' => $value)));
}
/**
* @return string log file name. Defaults to 'application.log'.
*/
public function getLogFile()
{
return $this->_logFile;
}
/**
* @param string $value log file name
*/
public function setLogFile($value)
{
$this->_logFile = $value;
}
/**
* @return integer maximum log file size in kilo-bytes (KB). Defaults to 1024 (1MB).
*/
public function getMaxFileSize()
{
return $this->_maxFileSize;
}
/**
* @param integer $value maximum log file size in kilo-bytes (KB).
*/
public function setMaxFileSize($value)
{
if (($this->_maxFileSize = (int)$value) <1)
$this->_maxFileSize = 1;
}
/**
* @return integer number of files used for rotation. Defaults to 5.
*/
public function getMaxLogFiles()
{
return $this->_maxLogFiles;
}
/**
* @param integer $value number of files used for rotation.
*/
public function setMaxLogFiles($value)
{
if (($this->_maxLogFiles = (int)$value) <1)
$this->_maxLogFiles = 1;
if ($this->logPath === null) {
$this->logPath = \Yii::app()->getRuntimePath();
}
if (!is_dir($this->logPath) || !is_writable($this->logPath)) {
throw new \yii\base\Exception("Directory '{$this->logPath}' does not exist or is not writable.");
}
if ($this->maxLogFiles <1){
$this->maxLogFiles = 1;
}
if ($this->maxFileSize <1){
$this->maxFileSize = 1;
}
}
/**
* Saves log messages in files.
* @param array $logs list of log messages
* Sends log [[messages]] to specified email addresses.
* @param boolean $final whether this method is called at the end of the current application