setName("api:logs") ->setDescription("Show previous requests and manage the log") ->addOption("clear", null, InputOption::VALUE_NONE, "Clear the log") ->addOption("write", "w", InputOption::VALUE_REQUIRED, "Write the formatted entries to a file") ; } protected function execute(InputInterface $input, OutputInterface $output) { /** @var ApiClientPlugin */ $plugin = get_plugin('com.noccy.apiclient'); $iter = $plugin->getLogIterator("default"); foreach ($iter as $index=>$log) { $this->dumpLog($log, $index, $output); } return Command::SUCCESS; } private function dumpLog(array $log, int $index, OutputInterface $output) { $output->writeln("#{$index} {$log['request']['info']['query']} ({$log['method']}) ".strlen($log['response']['body'])."b"); } }