2017-10-31 13:40:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Engelsystem\Logger;
|
|
|
|
|
|
|
|
use Engelsystem\Container\ServiceProvider;
|
2020-02-29 20:53:25 +01:00
|
|
|
use Engelsystem\Helpers\Authenticator;
|
2017-10-31 13:40:13 +01:00
|
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
|
|
|
|
class LoggerServiceProvider extends ServiceProvider
|
|
|
|
{
|
|
|
|
public function register()
|
|
|
|
{
|
2020-02-29 20:53:25 +01:00
|
|
|
$logger = $this->app->make(UserAwareLogger::class);
|
2017-10-31 13:40:13 +01:00
|
|
|
$this->app->instance('logger', $logger);
|
|
|
|
|
|
|
|
$this->app->bind(LoggerInterface::class, 'logger');
|
2020-02-29 20:53:25 +01:00
|
|
|
$this->app->bind(Logger::class, 'logger');
|
|
|
|
$this->app->bind(UserAwareLogger::class, 'logger');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
/** @var UserAwareLogger $logger */
|
|
|
|
$logger = $this->app->get(UserAwareLogger::class);
|
|
|
|
/** @var Authenticator $auth */
|
|
|
|
$auth = $this->app->get(Authenticator::class);
|
|
|
|
|
|
|
|
$logger->setAuth($auth);
|
2017-10-31 13:40:13 +01:00
|
|
|
}
|
|
|
|
}
|