private function getLogger($app)
 {
     if (!$this->logger) {
         $handlers = [];
         $config = $app['config'];
         if ($this->hasLogging($app)) {
             $webProcessor = new WebProcessor();
             $webProcessor->addExtraField('user_agent', 'HTTP_USER_AGENT');
             $processors = [$webProcessor, new IntrospectionProcessor()];
         } else {
             $processors = [];
             $handlers[] = new NullHandler();
         }
         $this->logger = new Monolog($config->get('app.hostname'), $handlers, $processors);
     }
     return $this->logger;
 }
Beispiel #2
0
 /**
  * @param array $loggerConfig
  *
  * @return array
  *
  * @throws MonologCreator\Exception
  */
 public function createProcessors(array $loggerConfig)
 {
     $processors = array();
     if (false === array_key_exists('processors', $loggerConfig) || false === is_array($loggerConfig['processors'])) {
         return $processors;
     }
     foreach ($loggerConfig['processors'] as $processor) {
         if ('web' === $processor) {
             $webProcessor = new Monolog\Processor\WebProcessor();
             $webProcessor->addExtraField('user_agent', 'HTTP_USER_AGENT');
             $processors[] = $webProcessor;
         } elseif ('requestId' === $processor) {
             $processors[] = new Processor\RequestId();
         } else {
             throw new MonologCreator\Exception('processor type: ' . $processor . ' is not supported');
         }
     }
     return $processors;
 }