PHPackages                             sebk/small-logger-bundle - 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-bundle

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

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

Symfony logger

1.0(3y ago)049GPL-3.0-onlyPHPPHP &gt;=8.0

Since Oct 21Pushed 3y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

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

[](#small-logger-bundle)

Symfony small logger

In reality, it is only a bridge between symfony and [small-logger](https://github.com/sebk69/small-logger).

Additionnaly, this package implement a symfony native http client for http output.

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)

Use composer to install the package in your symfony project :

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

Configure
---------

[](#configure)

First define service for SwitchLogicInterface :

```
# config/service.yaml
services:
  _defaults:
    autowire: true      # Automatically injects dependencies in your services.
    autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.

  App\:
    resource: '../src/'
    exclude:
      - '../src/DependencyInjection/'
      - '../src/Entity/'
      - '../src/Kernel.php'
      - '../src/Tests/'

  Sebk\SmallLogger\Contracts\SwitchLogicInterface:
    class: Sebk\SmallLogger\SwitchLogic\DefaultSwitchLogic
```

There is two default switches available in small-logger package :

- Sebk\\SmallLogger\\SwitchLogic\\DefaultSwitchLogic -&gt; log BasicLog to standard ouput
- Sebk\\SmallLogger\\SwitchLogic\\CommonLogSwitchLoggic -&gt; log CommonLog to file

See [small-logger documentation](https://github.com/sebk69/small-logger) to create your own switches, streams, formatters or logs

Create shortcuts
----------------

[](#create-shortcuts)

Shortcuts are callback that simplify writing of logs by developer.

You are required to declare them in the contructor of a class. For example :

```
namespace App\Log;

use Sebk\SmallLogger\Contracts\LogInterface;
use Sebk\SmallLogger\Log\BasicLog;
use Sebk\SmallLoggerBundle\Service\Logger;

class Shortcuts
{
    public function __construct(Logger $logger)
    {
        $logger->registerShortcut('info', function(Logger $logger, $message) {
            $logger->log(new BasicLog(new \DateTime(), LogInterface::ERR_LEVEL_INFO, $message));
        });
    }
}
```

And declare the Shortcuts class in config :

```
# config/packages/small_logger.yaml
small_logger:
  shortcuts:
    - App\Log\Shortcuts
```

After declaring callback, just call it via logger :

```
