/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $logger->debug('started checking for new version of remote file'); $browscap = $this->getBrowscap(); $browscap->setLogger($logger)->setCache($this->cache)->checkUpdate($input->getOption('remote-file')); $logger->debug('finished checking for new version of remote file'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $logger->info('started updating cache with remote file'); $browscap = $this->getBrowscap(); $browscap->setLogger($logger)->setCache($this->cache)->update(IniLoader::PHP_INI); $logger->info('finished updating cache with remote file'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $file = $input->getArgument('file'); if (!$file) { $file = $this->defaultIniFile; } $logger->info('started fetching remote file'); $browscap = $this->getBrowscap(); $browscap->setLogger($logger)->fetch($file, IniLoader::PHP_INI); $logger->info('finished fetching remote file'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $browscap = $this->getBrowscap(); $browscap->setLogger($logger)->setCache($this->cache); $result = $browscap->getBrowser($input->getArgument('user-agent')); if (!defined('JSON_PRETTY_PRINT')) { // not defined in PHP 5.3 define('JSON_PRETTY_PRINT', 128); } $output->writeln(json_encode($result, JSON_PRETTY_PRINT)); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $logger->info('initializing converting process'); $browscap = new BrowscapUpdater(); $browscap->setLogger($logger)->setCache($this->getCache($input)); $logger->info('started converting local file'); $file = $input->getArgument('file') ? $input->getArgument('file') : $this->defaultIniFile; $browscap->convertFile($file); $logger->info('finished converting local file'); }
/** * @param InputInterface $input * @param OutputInterface $output * * @throws \UnexpectedValueException * @throws \BrowscapPHP\Exception\InvalidArgumentException * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { if (!$input->getOption('log-file') && !$input->getOption('log-dir')) { throw InvalidArgumentException::oneOfCommandArguments('log-file', 'log-dir'); } $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $browscap = new Browscap(); $loader = new IniLoader(); $collection = ReaderFactory::factory(); $fs = new Filesystem(); $browscap->setLogger($logger)->setCache($this->getCache($input)); /** @var $file \Symfony\Component\Finder\SplFileInfo */ foreach ($this->getFiles($input) as $file) { $this->uas = []; $path = $this->getPath($file); $this->countOk = 0; $this->countNok = 0; $logger->info('Analyzing file "' . $file->getPathname() . '"'); $lines = file($path); if (empty($lines)) { $logger->info('Skipping empty file "' . $file->getPathname() . '"'); continue; } $this->totalCount = count($lines); foreach ($lines as $line) { $this->handleLine($output, $collection, $browscap, $line); } $this->outputProgress($output, '', true); arsort($this->uas, SORT_NUMERIC); try { $fs->dumpFile($input->getArgument('output') . '/output.txt', implode(PHP_EOL, array_unique($this->undefinedClients))); } catch (IOException $e) { // do nothing } try { $fs->dumpFile($input->getArgument('output') . '/output-with-amount.txt', $this->createAmountContent()); } catch (IOException $e) { // do nothing } try { $fs->dumpFile($input->getArgument('output') . '/output-with-amount-and-type.txt', $this->createAmountTypeContent()); } catch (IOException $e) { // do nothing } } $outputFile = $input->getArgument('output') . '/output.txt'; try { $fs->dumpFile($outputFile, implode(PHP_EOL, array_unique($this->undefinedClients))); } catch (IOException $e) { throw new \UnexpectedValueException('writing to file "' . $outputFile . '" failed', 0, $e); } try { $fs->dumpFile($input->getArgument('output') . '/output-with-amount.txt', $this->createAmountContent()); } catch (IOException $e) { // do nothing } try { $fs->dumpFile($input->getArgument('output') . '/output-with-amount-and-type.txt', $this->createAmountTypeContent()); } catch (IOException $e) { // do nothing } }
public function testCreateInDebugMode() { $helper = new LoggerHelper(); self::assertInstanceOf('\\Monolog\\Logger', $helper->create(true)); }