PHPackages                             travail/log-buffered - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. travail/log-buffered

ActiveLibrary

travail/log-buffered
====================

travail/log-buffered

v0.2.0(3y ago)1168.8k↓100%1PHP-3.0PHP

Since May 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/travail/php-Log-Buffered)[ Packagist](https://packagist.org/packages/travail/log-buffered)[ RSS](/packages/travail-log-buffered/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (3)Versions (4)Used By (0)

Log\\Beffered
=============

[](#logbeffered)

NAME
----

[](#name)

Log\\Buffered -

SYNOPSIS
--------

[](#synopsis)

```
use Log\Buffered;

require_once '/path/to/vendor/autoload.php';

$log = new Buffered(
    [
        'file'        => '/paht/to/myapp.log', // stderr by default
        'buffer_size' => 10240,                // 5120 bytes by default
    ]
);
$log->debugf('This is a %s message', 'debug'); // This message never be output
$log->infof('This is an %s message', 'info');
$log->warnf('This is a %s message', 'warn');
$log->critf('This is a %s message', 'crit');
```

INSTALLATION
------------

[](#installation)

To install this package into your project via composer, add the following snippet to your `composer.json`. Then run `composer install`.

```
"require": {
    "travail/log-buffered": "dev-master"
}

```

If you want to install from gihub, add the following:

```
"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:travail/php-Log-Buffered.git"
    }
]

```

DEPENDENCIES
------------

[](#dependencies)

Log\\Buffered has the dependency on the following:

- [Log\\Minimal](https://github.com/travail/php-Log-Minimal)

METHODS
-------

[](#methods)

### \_\_construct

[](#__construct)

`__constract(array $attrs)`

#### Parameters

[](#parameters)

`$attrs` can contain the keys below:

##### file

[](#file)

Path to a file into which logger writes.

##### color

[](#color)

Outputs colored messages if set a true value, `false` by default.

##### debug

[](#debug)

Outputs debug messages if set a true value, `false` by default.

##### log\_level

[](#log_level)

The lower limit of the log level. `info` by default. **NOTE: To output debug messages set `debug` to `log_level` and a true value to `debug`.**

##### trace\_level

[](#trace_level)

The depth of stack trace. `1` by default.

##### buffer\_size

[](#buffer_size)

Set the size of buffer which allow to buffer messages within given size. `5120 bytes` by default. You must specify this between `Log\Buffered::MIN_BUFFER_SIZE` and `Log\Buffered::MAX_BUFFER_SIZE`, or an `Exception` will be thrown.

### debugf

[](#debugf)

`void debugf(string $format [, mixed $val [, mixed ...]])`

### infof

[](#infof)

`void infof(string $format [, mixed $val [, mixed ...]])`

### warnf

[](#warnf)

`void infof(string $format [, mixed $val [, mixed ...]])`

### critf

[](#critf)

`void infof(string $format [, mixed $val [, mixed ...]])`

These methods above buffer messages until buffered messages reach `buffer_size` you specified. If you try to buffer messages more than `buffer_size` the logger will flush buffered messages automatically with the caution below.

```
***************************** CAUTION!!! **********************************
Flush the buffer, because the size of buffered messages reached 1024.
If you want to buffer more messages, set the more large size to buffer_size
in the constructor or by calling Log\Buffered::setBufferSize().

```

#### Parameters

[](#parameters-1)

The same as the built-in function `sprintf`.

### append

[](#append)

`void append(string $message)`

Append a given message to the buffer. Usually you don't have to use this directly.

#### Parameters

[](#parameters-2)

##### $message

[](#message)

A string to be buffered.

### flush

[](#flush)

`void flush(void)`

Flush buffered messages.

### clear

[](#clear)

`void clear(void)`

Clear the buffer.

### getMinBufferSize

[](#getminbuffersize)

`int getMinBufferSize(void)`

Returns the size of min buffer size `1024` bytes.

### getMaxBufferSize

[](#getmaxbuffersize)

`int getMaxBufferSize(void)`

Returns the size of max buffer size `5120000` bytes.

### getBufferedSize

[](#getbufferedsize)

`int getBufferedSize(void)`

Returns the size of buffered messages.

ENABLING DEBUG MESSAGES
-----------------------

[](#enabling-debug-messages)

There are two ways to enable debug messages:

1. By Environment Values
2. By Constructor

### By Environment Values

[](#by-environment-values)

```
$_SERVER['LM_DEBUG']     = true;
$_SERVER['LM_LOG_LEVEL'] = 'debug';
$log = new Log\Buffered();
$log->debugf('This is a %s message: %s', 'debug');
```

### By Constructor

[](#by-constructor)

```
$log = new Log\Buffered(
    [
        'debug'     => true,
        'log_level' => 'debug',
    ]
);
$log->debugf('This is a %s message: %s', 'debug');
```

AUTHOR
------

[](#author)

travail

LICENSE
-------

[](#license)

This library is free software. You can redistribute it and/or modify it under the same terms as PHP itself.

###  Health Score

33

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3043 days

Total

2

Last Release

1299d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/eababa87de505ba8eceaeee0a6ae217add7d71a3cb3a3723a198106282747119?d=identicon)[travail](/maintainers/travail)

---

Top Contributors

[![travail](https://avatars.githubusercontent.com/u/52314?v=4)](https://github.com/travail "travail (45 commits)")[![tisogawa](https://avatars.githubusercontent.com/u/145603?v=4)](https://github.com/tisogawa "tisogawa (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/travail-log-buffered/health.svg)

```
[![Health](https://phpackages.com/badges/travail-log-buffered/health.svg)](https://phpackages.com/packages/travail-log-buffered)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
