8000 [MonologBridge] Add completion for server:log by StaffNowa · Pull Request #43892 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[MonologBridge] Add completion for server:log #43892

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
* ServerLogCommand.php - autocomplete
  • Loading branch information
StaffNowa committed Nov 2, 2021
commit 2960c90f4ae3a78b5545d70bf633c043b0614856
36 changes: 36 additions & 0 deletions src/Symfony/Bridge/Monolog/Command/ServerLogCommand.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Symfony\Bridge\Monolog\Formatter\ConsoleFormatter;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\CompletionSuggestions;
use Symfony\Component\Console\Exception\LogicException;
use Symfony\Component\Console\Exception\RuntimeException;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -29,6 +31,24 @@
class ServerLogCommand extends Command
{
private const BG_COLOR = ['black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'];
private const HOST_OPTIONS = [
'0.0.0.0:9911',
'127.0.0.1:80',
'127.0.0.1:443',
'127.0.0.1:8000',
'http://0.0.0.0:9911',
'http://127.0.0.1:80',
'https://127.0.0.1:443',
'http://127.0.0.1:8000',
];

private const FORMAT_OPTIONS = [
'%datetime% %start_tag%%level_name%%end_tag% <comment>[%channel%]</> %message%%context%%extra%\n',
];

private const DATE_FORMAT_OPTIONS = [
'H:i:s',
];

private $el;
private $handler;
Expand Down Expand Up @@ -123,6 +143,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
return 0;
}

public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
if ($input->mustSuggestOptionValuesFor('host')) {
$suggestions->suggestValues(self::HOST_OPTIONS);
}

if ($input->mustSuggestOptionValuesFor('format')) {
$suggestions->suggestValues(self::FORMAT_OPTIONS);
}

if ($input->mustSuggestOptionValuesFor('date-format')) {
$suggestions->suggestValues(self::DATE_FORMAT_OPTIONS);
}
}


private function getLogs($socket): iterable
{
$sockets = [(int) $socket => $socket];
Expand Down
0