5 * Contains \Drupal\Console\Command\Database\LogDebugCommand.
8 namespace Drupal\Console\Command\Database;
10 use Symfony\Component\Console\Input\InputArgument;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Input\InputInterface;
13 use Symfony\Component\Console\Output\OutputInterface;
14 use Drupal\Component\Serialization\Yaml;
15 use Drupal\Console\Core\Style\DrupalStyle;
18 * Class LogDebugCommand
20 * @package Drupal\Console\Command\Database
22 class LogDebugCommand extends DatabaseLogBase
43 * Print in yml style if true
52 protected function configure()
55 ->setName('database:log:debug')
56 ->setDescription($this->trans('commands.database.log.debug.description'));
58 $this->addDefaultLoggingOptions();
63 InputArgument::OPTIONAL,
64 $this->trans('commands.database.log.debug.arguments.event-id')
69 InputOption::VALUE_NONE,
70 $this->trans('commands.database.log.debug.options.asc')
75 InputOption::VALUE_OPTIONAL,
76 $this->trans('commands.database.log.debug.options.limit')
81 InputOption::VALUE_OPTIONAL,
82 $this->trans('commands.database.log.debug.options.offset'),
88 InputOption::VALUE_NONE,
89 $this->trans('commands.database.log.debug.options.yml'),
97 protected function execute(InputInterface $input, OutputInterface $output)
99 $io = new DrupalStyle($input, $output);
101 $this->getDefaultOptions($input);
102 $this->eventId = $input->getArgument('event-id');
103 $this->asc = $input->getOption('asc');
104 $this->limit = $input->getOption('limit');
105 $this->offset = $input->getOption('offset');
106 $this->ymlStyle = $input->getOption('yml');
109 if ($this->eventId) {
110 return $this->getEventDetails($io);
112 return $this->getAllEvents($io);
121 private function getEventDetails(DrupalStyle $io)
123 $dblog = $this->database
125 'SELECT w.*, u.uid FROM {watchdog} w LEFT JOIN {users} u ON u.uid = w.uid WHERE w.wid = :id',
126 [':id' => $this->eventId]
133 $this->trans('commands.database.log.debug.messages.not-found'),
140 if ($this->ymlStyle) {
141 $io->writeln(Yaml::encode($this->formatSingle($dblog)));
144 $this->createTableHeader(),
145 [$this->createTableRow($dblog)]
151 * @param \Drupal\Console\Core\Style\DrupalStyle $io
154 private function getAllEvents(DrupalStyle $io)
156 $query = $this->makeQuery($io);
158 $result = $query->execute();
161 foreach ($result as $dblog) {
162 $tableRows[] = $this->createTableRow($dblog);
166 $this->createTableHeader(),