Skip to content

Commit 3f42615

Browse files
committed
Renamed command options. Moved from arguments to options as suggested in the review.
1 parent 3bb5d62 commit 3f42615

File tree

2 files changed

+40
-30
lines changed

2 files changed

+40
-30
lines changed

app/code/Magento/Developer/Console/Command/QueryLogEnableCommand.php

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
use Magento\Framework\DB\Logger\LoggerProxy;
1010
use Symfony\Component\Console\Command\Command;
11-
use Symfony\Component\Console\Input\InputArgument;
1211
use Symfony\Component\Console\Input\InputInterface;
12+
use Symfony\Component\Console\Input\InputOption;
1313
use Symfony\Component\Console\Output\OutputInterface;
1414
use Magento\Framework\App\DeploymentConfig\Writer;
1515
use Magento\Framework\Config\File\ConfigFilePool;
@@ -19,17 +19,17 @@ class QueryLogEnableCommand extends Command
1919
/**
2020
* input parameter log-all-queries
2121
*/
22-
const INPUT_ARG_LOG_ALL_QUERIES = 'log-all-queries';
22+
const INPUT_ARG_LOG_ALL_QUERIES = 'include-all-queries';
2323

2424
/**
2525
* input parameter log-query-time
2626
*/
27-
const INPUT_ARG_LOG_QUERY_TIME = 'log-query-time';
27+
const INPUT_ARG_LOG_QUERY_TIME = 'query-time-threshold';
2828

2929
/**
3030
* input parameter log-call-stack
3131
*/
32-
const INPUT_ARG_LOG_CALL_STACK = 'log-call-stack';
32+
const INPUT_ARG_LOG_CALL_STACK = 'include-call-stack';
3333

3434
/**
3535
* command name
@@ -65,28 +65,32 @@ public function __construct(
6565
protected function configure()
6666
{
6767
$this->setName(self::COMMAND_NAME)
68-
->setDescription('Enable DB query logging');
69-
70-
$this->addArgument(
71-
self::INPUT_ARG_LOG_ALL_QUERIES,
72-
InputArgument::OPTIONAL,
73-
'Log all queries. Options: "true" or "false"',
74-
'true'
75-
);
76-
77-
$this->addArgument(
78-
self::INPUT_ARG_LOG_QUERY_TIME,
79-
InputArgument::OPTIONAL,
80-
'Log query time.',
81-
'0.001'
82-
);
83-
84-
$this->addArgument(
85-
self::INPUT_ARG_LOG_CALL_STACK,
86-
InputArgument::OPTIONAL,
87-
'Log call stack. Options: "true" or "false"',
88-
'true'
89-
);
68+
->setDescription('Enable DB query logging')
69+
->setDefinition(
70+
[
71+
new InputOption(
72+
self::INPUT_ARG_LOG_ALL_QUERIES,
73+
null,
74+
InputOption::VALUE_OPTIONAL,
75+
'Log all queries. [true|false]',
76+
"true"
77+
),
78+
new InputOption(
79+
self::INPUT_ARG_LOG_QUERY_TIME,
80+
null,
81+
InputOption::VALUE_OPTIONAL,
82+
'Query time thresholds.',
83+
"0.001"
84+
),
85+
new InputOption(
86+
self::INPUT_ARG_LOG_CALL_STACK,
87+
null,
88+
InputOption::VALUE_OPTIONAL,
89+
'Include call stack. [true|false]',
90+
"true"
91+
),
92+
]
93+
);
9094

9195
parent::configure();
9296
}
@@ -99,9 +103,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
99103
{
100104
$data = [LoggerProxy::PARAM_ALIAS => LoggerProxy::LOGGER_ALIAS_FILE];
101105

102-
$logAllQueries = $input->getArgument(self::INPUT_ARG_LOG_ALL_QUERIES);
103-
$logQueryTime = $input->getArgument(self::INPUT_ARG_LOG_QUERY_TIME);
104-
$logCallStack = $input->getArgument(self::INPUT_ARG_LOG_CALL_STACK);
106+
$logAllQueries = $input->getOption(self::INPUT_ARG_LOG_ALL_QUERIES);
107+
$logQueryTime = $input->getOption(self::INPUT_ARG_LOG_QUERY_TIME);
108+
$logCallStack = $input->getOption(self::INPUT_ARG_LOG_CALL_STACK);
105109

106110
$data[LoggerProxy::PARAM_LOG_ALL] = (int)($logAllQueries != 'false');
107111
$data[LoggerProxy::PARAM_QUERY_TIME] = number_format($logQueryTime, 3);

app/code/Magento/Developer/Test/Unit/Console/Command/QueryLogEnableCommandTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,13 @@ public function testExecuteWithParams()
8686
->with([ConfigFilePool::APP_ENV => [LoggerProxy::CONF_GROUP_NAME => $data]]);
8787

8888
$commandTester = new CommandTester($this->command);
89-
$commandTester->execute(['false', '0.05', 'false']);
89+
$commandTester->execute(
90+
[
91+
'--include-all-queries' => 'false',
92+
'--include-call-stack' => 'false',
93+
'--query-time-threshold' => '0.05',
94+
]
95+
);
9096
$this->assertSame(
9197
QueryLogEnableCommand::SUCCESS_MESSAGE . PHP_EOL,
9298
$commandTester->getDisplay()

0 commit comments

Comments
 (0)