PHPackages                             sebk/small-logger - 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. [Logging &amp; Monitoring](/categories/logging)
4. /
5. sebk/small-logger

AbandonedArchivedLibrary[Logging &amp; Monitoring](/categories/logging)

sebk/small-logger
=================

A small logger

1.1.1(3y ago)01.3k↓50%1GPL-3.0-onlyPHPPHP &gt;=8.0

Since Oct 17Pushed 3y ago1 watchersCompare

[ Source](https://github.com/sebk69/small-logger)[ Packagist](https://packagist.org/packages/sebk/small-logger)[ RSS](/packages/sebk-small-logger/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (6)Used By (1)

small-logger
============

[](#small-logger)

Small logger is a simple php logger you can easily extends for your own need.

Basically, it implements possibility to log to : Standard output File (With log rotates) Http service such as logstash

It it easy to implement your own Formatter or Output writer.

SwitchLogicInterface allow you to implements your own logic to manage multiple log streams.

It also possible to add shortcut to logger for easier use by final developer.

Migrated
========

[](#migrated)

This lib has been migrated to [framagit](https://framagit.org/small) project.

A new composer package is available at

Future commits will be done on framagit.

Install
-------

[](#install)

```
composer require sebk/small-logger
```

Log to standard output
----------------------

[](#log-to-standard-output)

First define the switch loggic :

```
\Sebk\SmallLogger\Logger::setSwitchLogic(new \Sebk\SmallLogger\SwitchLogic\DefaultSwitchLogic());
```

Then, you are abble to log :

```
\Sebk\SmallLogger\Logger::log(new \Sebk\SmallLogger\Log\BasicLog(
    new \DateTime(),
    \Sebk\SmallLogger\Contracts\LogInterface::ERR_LEVEL_INFO,
    'This is an info log'
));
```

Log to file
-----------

[](#log-to-file)

You can log to a single file :

```
\Sebk\SmallLogger\Logger::setSwitchLogic(new \Sebk\SmallLogger\SwitchLogic\DefaultFileSwitchLogic('/var/log/my-log.log'));
```

Or redirect errors to another file :

```
\Sebk\SmallLogger\Logger::setSwitchLogic(new \Sebk\SmallLogger\SwitchLogic\DefaultFileSwitchLogic('/var/log/my-log.log', '/var/log/my-error-log.log'));
```

In the second case, errors are redirected to the second file.

Then this call will write in '/var/log/my-log.log' :

```
\Sebk\SmallLogger\Logger::log(new \Sebk\SmallLogger\Log\BasicLog(
    new \DateTime(),
    \Sebk\SmallLogger\Contracts\LogInterface::ERR_LEVEL_INFO,
    'This is an info log'
));
```

And this call will write in '/var/log/my-error-log.log' :

```
\Sebk\SmallLogger\Logger::log(new \Sebk\SmallLogger\Log\BasicLog(
    new \DateTime(),
    \Sebk\SmallLogger\Contracts\LogInterface::ERR_LEVEL_ERROR,
    'This is an info log'
));
```

Customizing logs
----------------

[](#customizing-logs)

You can easy customize the behaviour of logs by writing your own classes implementing interfaces :

- switch : the switch logic
- formatter : log class diggest to log format
- output : the output writer

For example, we want to write to logstash. We will use the http type with the output factory. To get the best appropriate output for your project, use the output factory :

```
$output = (new \Sebk\SmallLogger\Output\OutputFactory())->get('http', new \Sebk\SmallLogger\Output\Config\HttpConfig('localhost', 8080, false));
```

New we have the output, we can create our switcher :

```
namespace App\Logs;

class HttpSwitcherLogic implements \Sebk\SmallLogger\Contracts\SwitchLogicInterface
{

    protected \Sebk\SmallLogger\Contracts\StreamInterface $stream;

    public function __construct(\Sebk\SmallLogger\Output\Config\HttpConfig $config)
    {
        $this->stream = new \Sebk\SmallLogger\Stream\Stream(
            new \Sebk\SmallLogger\Formatter\JsonFormatter(),
            (new \Sebk\SmallLogger\Output\OutputFactory())->get('http', $config)
        );
    }

    public function getStream(\Sebk\SmallLogger\Contracts\LogInterface $log, array $data = []) : \Sebk\SmallLogger\Contracts\StreamInterface
    {
        $this->stream;
    }

}
```

In the getStream method, you can put your logic to manage more than one stream depends on $log itself or additional $data.

For example, you can set up a stream for error level and a stream for critical level.

If you want, the $data array may inject information to switch in complex architectures.

Now define your switch in logger and log :

```
\Sebk\SmallLogger\Logger::setSwitchLogic(new HttpSwitcher(
    new \Sebk\SmallLogger\Output\Config\HttpConfig(
        'logstash.my-domain.com',
        8080,
        true
    )
));
\Sebk\SmallLogger\Logger::log(new \Sebk\SmallLogger\Log\BasicLog(
    new \DateTime(),
    \Sebk\SmallLogger\Contracts\LogInterface::ERR_LEVEL_ERROR,
    'This an error'
));
```

Unit tests
----------

[](#unit-tests)

To run unit tests, you are require to build unit-test container :

```
$ sudo apt-get update && apt-get install docker docker-compose
$ docker-compose up -d --build
```

Then the container will build environement for testing and launch tests.

If you want to develop and add unit tests, turn off the **BUILD** environement var in docker-compose.yml by setting it to 0 :

```
...
    environment:
      - BUILD=1 # If set to 0, the unit test are not launched and container will sleep to let you run all tests commands you want when you develop tests
...

```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~7 days

Total

4

Last Release

1286d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/45cdb3e169cfc71f586543af872d5a48416b21c4ebb43060bcb8c96eebf3ff5d?d=identicon)[sebk69](/maintainers/sebk69)

---

Top Contributors

[![sebk69](https://avatars.githubusercontent.com/u/6600508?v=4)](https://github.com/sebk69 "sebk69 (13 commits)")

---

Tags

loggerphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sebk-small-logger/health.svg)

```
[![Health](https://phpackages.com/badges/sebk-small-logger/health.svg)](https://phpackages.com/packages/sebk-small-logger)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[ekino/newrelic-bundle

Integrate New Relic into Symfony2

28111.2M8](/packages/ekino-newrelic-bundle)

PHPackages © 2026

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