public function createLogger(Domain\Core\Config $config) : Logger
 {
     $c = $config->get('logging');
     $outputs = [];
     $configuredOutputs = $c->get('outputs');
     for ($i = 0; $i < \count($configuredOutputs); $i++) {
         $output = $configuredOutputs[$i];
         if (isset($output->format) === false) {
             $output->format = '{date} {time} {level}';
         }
         switch ($output->type) {
             case 'console':
                 $outputs[] = new ConsoleOutput($output->format);
                 break;
             case 'syslog':
                 if (isset($output->ident) === false) {
                     $output->ident = 'dashboard';
                 }
                 $outputs[] = new SyslogOutput($output->ident, $output->format);
                 break;
             default:
                 throw new \RuntimeError('Unsupported Logger output ' . $output->type);
         }
     }
     return new ConcreteLogger(new LogLevel($c->get('threshold')), $outputs);
 }
示例#2
0
 /**
  * Bootstraps the backend. This function registers an auto loader, parses the configuration
  * file, configures error handling and logging and finally hands over control to the
  * Router.
  * Both the configuration and the logger instance are stored in the 
  * Dashboard\Backend\Application\LifeCycle\RequestScope, with the respective keys *config* 
  * and *logger*.
  *
  * @param \stdClass $config The configuration object.
  * @return void
  */
 public function bootstrap(\stdClass $config)
 {
     \spl_autoload_register('Dashboard\\Backend\\Application\\Control\\Autoloader::autoload', true, true);
     $this->configureErrorHandling();
     $config = new Config($config);
     $sessionService = new Domain\Session\SessionService();
     $session = $sessionService->createSession($config->get('session'));
     $session->start();
     $psrService = new Domain\Psr\PsrService();
     RequestScope::instance()->set('config', $config);
     RequestScope::instance()->set('logger', $psrService->createLogger($config));
     RequestScope::instance()->set('session', $session);
 }
 public function createSession(Config $config) : Session
 {
     return new Session(array('cookie_lifetime' => $config->get('cookie_lifetime')));
 }