Logger Aware Service for Symfony
This bundle injects @logger service to any service that extends Silvioq\LASBundle\LoggerAwareService, (*1)
, (*2)
Register your bundle, (*3)
# 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 ..., (*4)
# service.yml
service:
my.awesome.service:
class: My\AwesomeService
... and log anything, (*5)
```php, (*6)
My/AwesomeService.php
namespace My;
use Silvioq\LASBundle\LoggerAwareService;, (*7)
class AwesomeService extends LoggerAwareService
{, (*8)
public function awesomeFunction()
{
// ...
$this->getLogger()->info( "Log anything");
}
}, (*9)