silvioq/logger-aware-service

Abstract class to automatize loggin in own services

v1.0.1 2017-04-27 12:57 UTC

This package is not auto-updated.

Last update: 2024-04-19 18:53:04 UTC


README

This bundle injects @logger service to any service that extends Silvioq\LASBundle\LoggerAwareService

Build Status

Register your bundle

# app/AppKernel.php

use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Config\Loader\LoaderInterface;

class AppKernel extends Kernel 
{   
    public function registerBundles()
    {
        $bundles = [  
            ...
            new Silvioq\LASBundle\LoggerAwareService(),
        ];
    }
}

Declare your service ...

# service.yml
service:
   my.awesome.service:
      class: My\AwesomeService

... and log anything

# My/AwesomeService.php
namespace My;
use Silvioq\LASBundle\LoggerAwareService;

class AwesomeService  extends LoggerAwareService
{

    public function awesomeFunction()
    {
        // ...
        $this->getLogger()->info( "Log anything");
    }

}