Parameters are {@link $datePattern}, {@link $file}. Note that file
* parameter should include a '%s' identifier and should always be set
* before {@link $file} param.
*
* @author Abel Gonzalez
* @author Knut Urdalen
* @version $Revision: 635069 $
* @package log4php
* @subpackage appenders
*/
class LoggerAppenderDailyFile extends LoggerAppenderFile {
/**
* Format date.
* It follows the {@link PHP_MANUAL#date()} formatting rules and should always be set before {@link $file} param.
* @var string
*/
public $datePattern = "Ymd";
/**
* Sets date format for the file name.
* @param string $format a regular date() string format
*/
public function setDatePattern($format) {
$this->datePattern = $format;
}
/**
* @return string returns date format for the filename
*/
public function getDatePattern() {
return $this->datePattern;
}
/**
* The File property takes a string value which should be the name of the file to append to.
* Sets and opens the file where the log output will go.
*
* @see LoggerAppenderFile::setFile()
*/
public function setFile() {
$numargs = func_num_args();
$args = func_get_args();
if ($numargs == 1 and is_string($args[0])) {
parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())) );
} elseif ($numargs == 2 and is_string($args[0]) and is_bool($args[1])) {
parent::setFile( sprintf((string)$args[0], date($this->getDatePattern())), $args[1] );
}
}
}