/** * @return Logger */ public function getLogger() { if (null === $this->logger) { $this->logger = new Logger(get_called_class()); $this->logger->pushHandler(new NullHandler()); } return $this->logger; }
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()]); }
public function testCountErrorsWithoutDebugHandler() { $logger = new Logger('test'); $logger->pushHandler(new TestHandler()); $logger->addInfo('test'); $logger->addError('uh-oh'); $this->assertEquals(0, $logger->countErrors()); }
/** * @return Logger */ public function getLogger() { if (null === $this->logger) { $this->logger = new Logger(__CLASS__); $this->logger->pushHandler(new NullHandler()); } return $this->logger; }
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); }
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']); }
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)); }