Skip to content

Commit

Permalink
Auto-close streams when reset() is called, fixes #1862
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldaek committed Nov 11, 2024
1 parent 24a1110 commit 0c73661
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Monolog/Handler/StreamHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ public function __construct($stream, int|string|Level $level = Level::Debug, boo
$this->useLocking = $useLocking;
}

/**
* @inheritDoc
*/
public function reset(): void
{
parent::reset();

// auto-close on reset to make sure we periodically close the file in long running processes
// as long as they correctly call reset() between jobs
if ($this->url !== null && $this->url !== 'php://memory') {
$this->close();
}
}

/**
* @inheritDoc
*/
Expand Down

0 comments on commit 0c73661

Please sign in to comment.