PHPackages                             spacetab-io/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. spacetab-io/logger

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

spacetab-io/logger
==================

Non-blocking logging for PHP based on Amp and Monolog. Without fucking brackets.

2.1.0(3y ago)251516MITPHPPHP &gt;=8.1

Since Apr 5Pushed 3y ago3 watchersCompare

[ Source](https://github.com/spacetab-io/logger-php)[ Packagist](https://packagist.org/packages/spacetab-io/logger)[ RSS](/packages/spacetab-io-logger/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (6)

Simple pre-configured Monolog wrapper
-------------------------------------

[](#simple-pre-configured-monolog-wrapper)

[![CircleCI](https://camo.githubusercontent.com/09bc8030dc9389c8a38ed7b177fbc08a4eae975b96e8bdd5a89a2b61914267ae/68747470733a2f2f636972636c6563692e636f6d2f67682f73706163657461622d696f2f6c6f676765722d7068702e7376673f7374796c653d737667)](https://circleci.com/gh/spacetab-io/logger-php)[![codecov](https://camo.githubusercontent.com/cefedf1e04132b8554ca0a0dedf971a98e907f1e396432d0eb6ce729627153d5/68747470733a2f2f636f6465636f762e696f2f67682f73706163657461622d696f2f6c6f676765722d7068702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/spacetab-io/logger-php)

Since `2.0.0` logger is non-blocking and based on Amp and Monolog.

I create this library with one target, — I'm sick of always copies and paste same code to any of my microservices with logs.

This wrapper solves one problem with logs. And this problem, — fucking brackets -&gt; \[\] \[\] \[\] \[\].

Example, how this wrapper present the logs:

```
[2019-04-29 21:39:52] Server.INFO: CONFIG_PATH = ./configuration
[2019-04-29 21:39:52] Server.INFO: STAGE = local
[2019-04-29 21:39:52] Server.INFO: Configuration module loaded
[2019-04-29 21:39:52] Server.INFO: HTTP static server started at 0.0.0.0:8080

```

This is a normal view and without fucking brackets of Monolog's. Okay, I'm hate it too, how it uses?

Usage
-----

[](#usage)

1. Install library through `composer`:

```
composer require spacetab-io/logger
```

1. Basic example for most cases will do like as:

```
use Spacetab\Logger\Logger;

$log = Logger::default(); // Psr\Log\LoggerInterface
$log->info('write something');
```

2. If you want register this library thought Service Provider (add to application DI container), see this example:

Note: this is a pseudocode for example.

```
use Monolog\Logger;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;

class LoggerModule implements ServiceProvider
{
    /**
     * @param ContainerInterface $container
     */
    public function provideServices($container): void
    {
        $container->register(LoggerInterface::class, function () {
            return Logger::default(); // it's all!
        });
    }
}
```

3. How to register logger without static:: method? It also very simple.

```
