Skip to content

Commit

Permalink
Fix patch
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 11, 2024
1 parent d57089b commit d2d0341
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Monolog/Handler/RotatingFileHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,22 @@ public function setFilenameFormat(string $filenameFormat, string $dateFormat): s
*/
protected function write(array $record): void
{
// on the first record written, if the log is new, we should rotate (once per day)
// on the first record written, if the log is new, we rotate (once per day) after the log has been written so that the new file exists
if (null === $this->mustRotate) {
$this->mustRotate = null === $this->url || !file_exists($this->url);
if ($this->mustRotate) {
$this->close(); // triggers rotation
}
}

// if the next rotation is expired, then we rotate immediately
if ($this->nextRotation <= $record['datetime']) {
$this->mustRotate = true;
$this->close(); // triggers rotation
}

parent::write($record);

if ($this->mustRotate) {
$this->close(); // triggers rotation
}
}

/**
Expand Down

0 comments on commit d2d0341

Please sign in to comment.