setName('analyze') ->setDescription('analyze log file') ->setHelp('This command analyzes a log file') ->addOption('output', null, InputOption::VALUE_NONE, 'Print the HTML log text') ->addOption('out', 'file', InputOption::VALUE_REQUIRED, 'File to write HTML log text to') ->addArgument('file', InputArgument::REQUIRED, 'Log file to analyze'); } protected function execute(InputInterface $input, OutputInterface $output) { $filename = $input->getArgument('file'); if (!file_exists($filename)) { $output->writeln("Invalid file"); return 1; } $logchecker = new Logchecker(); $logchecker->newFile($filename); $logchecker->parse(); $output->writeln('Ripper : ' . $logchecker->getRipper()); $output->writeln('Version : ' . $logchecker->getVersion()); $output->writeln('Score : ' . $logchecker->getScore()); $output->writeln('Checksum: ' . $logchecker->getChecksumState()); $details = $logchecker->getDetails(); if (count($details) > 0) { $output->writeln('Details :'); foreach ($details as $detail) { $output->writeln(' ' . $detail); } } if ($input->getOption('output')) { $output->writeln(''); $output->writeln('Log Text:'); $output->writeln($logchecker->getLog()); } if ($input->getOption('out')) { $html_out = << Test
{$logchecker->getLog()}
HTML; file_put_contents($input->getOption('out'), $html_out); } return 0; } }