46 $this->nextRotation = new \DateTime(
'tomorrow');
47 $this->filenameFormat =
'{filename}-{date}';
48 $this->dateFormat =
'Y-m-d';
60 if (
true === $this->mustRotate) {
76 protected function write(array $record)
79 if (null === $this->mustRotate) {
80 $this->mustRotate = !file_exists($this->url);
83 if ($this->nextRotation < $record[
'datetime']) {
84 $this->mustRotate =
true;
88 parent::write($record);
98 $this->nextRotation = new \DateTime(
'tomorrow');
101 if (0 === $this->maxFiles) {
106 if ($this->maxFiles >= count($logFiles)) {
112 usort($logFiles,
function ($a, $b) {
113 return strcmp($b, $a);
116 foreach (array_slice($logFiles, $this->maxFiles) as
$file) {
117 if (is_writable(
$file)) {
125 $fileInfo = pathinfo($this->filename);
126 $timedFilename = str_replace(
127 array(
'{filename}',
'{date}'),
128 array($fileInfo[
'filename'], date($this->dateFormat)),
129 $fileInfo[
'dirname'] .
'/' . $this->filenameFormat
132 if (!empty($fileInfo[
'extension'])) {
133 $timedFilename .=
'.'.$fileInfo[
'extension'];
136 return $timedFilename;
141 $fileInfo = pathinfo($this->filename);
143 array(
'{filename}',
'{date}'),
144 array($fileInfo[
'filename'],
'*'),
145 $fileInfo[
'dirname'] .
'/' . $this->filenameFormat
147 if (!empty($fileInfo[
'extension'])) {
148 $glob .=
'.'.$fileInfo[
'extension'];
const DEBUG
Detailed debug information.
Stores logs to files that are rotated every day and a limited number of files are kept...
__construct($filename, $maxFiles=0, $level=Logger::DEBUG, $bubble=true, $filePermission=null, $useLocking=false)
rotate()
Rotates the files.
Stores to any stream resource.
setFilenameFormat($filenameFormat, $dateFormat)