[GH-ISSUE #120] Always do count on buffer array not a good idea #40

Closed
opened 2026-03-04 02:11:36 +03:00 by kerem · 0 comments
Owner

Originally created by @omgnull on GitHub (Sep 20, 2012).
Original GitHub issue: https://github.com/Seldaek/monolog/issues/120

This issue for all buffered handlers.

    $this->buffer[] = $record;
    if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) {
        array_shift($this->buffer);
    }

Better its shoud be independent counter and change the name "size" to "limit"

    $this->buffer[] = $record;
    $this->bufferSize++;
    if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) {
        array_shift($this->buffer);
        $this->bufferSize--;
    }

Or add option to flush records if buffer is full

Originally created by @omgnull on GitHub (Sep 20, 2012). Original GitHub issue: https://github.com/Seldaek/monolog/issues/120 This issue for all buffered handlers. ``` php $this->buffer[] = $record; if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { array_shift($this->buffer); } ``` Better its shoud be independent counter and change the name "size" to "limit" ``` php $this->buffer[] = $record; $this->bufferSize++; if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) { array_shift($this->buffer); $this->bufferSize--; } ``` Or add option to flush records if buffer is full
kerem closed this issue 2026-03-04 02:11:37 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/monolog#40
No description provided.