예제 #1
0
 /**
  * @return Logger
  */
 public function getLogger()
 {
     if (null === $this->logger) {
         $this->logger = new Logger(get_called_class());
         $this->logger->pushHandler(new NullHandler());
     }
     return $this->logger;
 }
예제 #2
0
 protected function initialize(InputInterface $input, OutputInterface $output)
 {
     $this->logger = new Logger($this->getName());
     $this->logger->pushHandler(new ConsoleHandler($output));
     $this->logger->pushProcessor(new MemoryPeakUsageProcessor());
     if (!empty($this->getConfig()->getLogFilename())) {
         $this->logger->pushHandler(new StreamHandler($this->getConfig()->getLogFilename()));
     }
     $this->symfonyStyle = new SymfonyStyle($input, $output);
     $this->getLogger()->debug('Config file', ['file' => $this->getApplication()->getConfigDefaultPath()]);
 }
예제 #3
0
 public function testCountErrorsWithoutDebugHandler()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new TestHandler());
     $logger->addInfo('test');
     $logger->addError('uh-oh');
     $this->assertEquals(0, $logger->countErrors());
 }
예제 #4
0
 /**
  * @return Logger
  */
 public function getLogger()
 {
     if (null === $this->logger) {
         $this->logger = new Logger(__CLASS__);
         $this->logger->pushHandler(new NullHandler());
     }
     return $this->logger;
 }
예제 #5
0
 public function redirect($path, $route, $scheme = null, $logPath = null)
 {
     if ($logPath) {
         $logger = new Logger('redirect');
         $logger->pushHandler(new StreamHandler($logPath, Logger::INFO));
         $logger->addInfo('redirect', ['url' => $this->context->getPathInfo() . '?' . $this->context->getQueryString(), 'location' => $path, 'method' => $this->context->getMethod()]);
     }
     return parent::redirect($path, $route, $scheme);
 }
예제 #6
0
 public function testGetLogs()
 {
     $logger = new Logger('test');
     $logger->pushHandler(new DebugHandler());
     $logger->addInfo('test');
     $this->assertCount(1, $logger->getLogs());
     list($record) = $logger->getLogs();
     $this->assertEquals('test', $record['message']);
     $this->assertEquals(Logger::INFO, $record['priority']);
 }
예제 #7
0
 private function delToLog(Friend $friend)
 {
     $log = new Logger('friendchanel');
     $log->pushHandler(new StreamHandler($this->path_file_log, Logger::INFO));
     $log->addInfo('Del Old Friend:' . $this->getInfoFriend($friend));
 }