Added --debug flag to combine all the debug flags

We have also made it so if you use --logfile flag the output to console is suppressed to reduce noise.
This commit is contained in:
abdulmohsen
2024-02-01 15:45:05 +03:00
parent acf8d0b8e4
commit 9f3445a430
4 changed files with 21 additions and 2 deletions

View File

@@ -77,6 +77,15 @@ class Cli extends Application
)
);
$definition->addOption(
new InputOption(
'debug',
null,
InputOption::VALUE_NONE,
'Turn on the <comment>-vvv --context --trace</comment> flags.'
)
);
return $definition;
}
}

View File

@@ -48,6 +48,16 @@ class Command extends BaseCommand
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($input->hasOption('debug') && $input->getOption('debug')) {
$input->setOption('context', true);
$input->setOption('trace', true);
$input->setOption('verbose', true);
if (function_exists('putenv')) {
@putenv('SHELL_VERBOSITY=3');
}
$output->setVerbosity(OutputInterface::VERBOSITY_DEBUG);
}
if ($input->hasOption('context') && true === $input->getOption('context')) {
Config::save('logs.context', true);
}

View File

@@ -140,7 +140,7 @@ class ExportCommand extends Command
protected function process(InputInterface $input, OutputInterface $output): int
{
if (null !== ($logfile = $input->getOption('logfile')) && true === ($this->logger instanceof Logger)) {
$this->logger->pushHandler(new StreamLogHandler(new Stream($logfile, 'a'), $output));
$this->logger->setHandlers([new StreamLogHandler(new Stream($logfile, 'w'), $output)]);
}
// -- Use Custom servers.yaml file.

View File

@@ -239,7 +239,7 @@ class ImportCommand extends Command
protected function process(InputInterface $input, OutputInterface $output): int
{
if (null !== ($logfile = $input->getOption('logfile')) && true === ($this->logger instanceof Logger)) {
$this->logger->pushHandler(new StreamLogHandler(new Stream($logfile, 'a'), $output));
$this->logger->setHandlers([new StreamLogHandler(new Stream($logfile, 'w'), $output)]);
}
// -- Use Custom servers.yaml file.