should always be set before {@link $file} param. * @var string */ protected $datePattern = "Ymd"; /** * Sets date format for the file name. * @param string $datePattern a regular date() string format */ public function setDatePattern($datePattern) { $this->setString('datePattern', $datePattern); } /** * @return string returns date format for the filename */ public function getDatePattern() { return $this->datePattern; } /** * Similar to parent method, but but replaces "%s" in the file name with * the current date in format specified by the 'datePattern' parameter. */ public function activateOptions() { $fileName = $this->getFile(); $date = date($this->getDatePattern()); $fileName = sprintf($fileName, $date); if(!is_file($fileName)) { $dir = dirname($fileName); if(!is_dir($dir)) { mkdir($dir, 0777, true); } } $this->fp = fopen($fileName, ($this->getAppend()? 'a':'w')); if($this->fp) { if(flock($this->fp, LOCK_EX)) { if($this->getAppend()) { fseek($this->fp, 0, SEEK_END); } fwrite($this->fp, $this->layout->getHeader()); flock($this->fp, LOCK_UN); $this->closed = false; } else { // TODO: should we take some action in this case? $this->closed = true; } } else { $this->closed = true; } } }