File Log writer without newline. (#19941)

* File Log writer without newline.

* Fix minor correction.

* Fix tests.

* Add more test.

* Add line to CHANGELOG.md.
This commit is contained in:
Wilmer Arambula
2023-08-30 08:14:12 -04:00
committed by GitHub
parent a2ee22044c
commit 671fbefe84
3 changed files with 16 additions and 4 deletions

View File

@ -130,12 +130,12 @@ class FileTarget extends Target
if ($this->enableRotation && @filesize($this->logFile) > $this->maxFileSize * 1024) {
$this->rotateFiles();
}
$writeResult = @fwrite($fp, $trimmedText);
$writeResult = @fwrite($fp, $text);
if ($writeResult === false) {
$error = error_get_last();
throw new LogRuntimeException("Unable to export log through file ({$this->logFile})!: {$error['message']}");
}
$textSize = strlen($trimmedText);
$textSize = strlen($text);
if ($writeResult < $textSize) {
throw new LogRuntimeException("Unable to export whole log through file ({$this->logFile})! Wrote $writeResult out of $textSize bytes.");
}