8
8
9
9
use Magento \Framework \DB \Logger \LoggerProxy ;
10
10
use Symfony \Component \Console \Command \Command ;
11
- use Symfony \Component \Console \Input \InputArgument ;
12
11
use Symfony \Component \Console \Input \InputInterface ;
12
+ use Symfony \Component \Console \Input \InputOption ;
13
13
use Symfony \Component \Console \Output \OutputInterface ;
14
14
use Magento \Framework \App \DeploymentConfig \Writer ;
15
15
use Magento \Framework \Config \File \ConfigFilePool ;
@@ -19,17 +19,17 @@ class QueryLogEnableCommand extends Command
19
19
/**
20
20
* input parameter log-all-queries
21
21
*/
22
- const INPUT_ARG_LOG_ALL_QUERIES = 'log -all-queries ' ;
22
+ const INPUT_ARG_LOG_ALL_QUERIES = 'include -all-queries ' ;
23
23
24
24
/**
25
25
* input parameter log-query-time
26
26
*/
27
- const INPUT_ARG_LOG_QUERY_TIME = 'log- query-time ' ;
27
+ const INPUT_ARG_LOG_QUERY_TIME = 'query-time-threshold ' ;
28
28
29
29
/**
30
30
* input parameter log-call-stack
31
31
*/
32
- const INPUT_ARG_LOG_CALL_STACK = 'log -call-stack ' ;
32
+ const INPUT_ARG_LOG_CALL_STACK = 'include -call-stack ' ;
33
33
34
34
/**
35
35
* command name
@@ -65,28 +65,32 @@ public function __construct(
65
65
protected function configure ()
66
66
{
67
67
$ 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
+ );
90
94
91
95
parent ::configure ();
92
96
}
@@ -99,9 +103,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
99
103
{
100
104
$ data = [LoggerProxy::PARAM_ALIAS => LoggerProxy::LOGGER_ALIAS_FILE ];
101
105
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 );
105
109
106
110
$ data [LoggerProxy::PARAM_LOG_ALL ] = (int )($ logAllQueries != 'false ' );
107
111
$ data [LoggerProxy::PARAM_QUERY_TIME ] = number_format ($ logQueryTime , 3 );
0 commit comments