Improved ConsoleLogger to support running in watcher (#7033)

This commit is contained in:
Deeka Wong 2024-08-29 15:00:38 +08:00 committed by GitHub
parent 0fed0fd0a3
commit 1c295f204a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 18 additions and 3 deletions

View File

@ -1,5 +1,9 @@
# v3.1.39 - TBD
## Optimized
- [#7033](https://github.com/hyperf/hyperf/pull/7033) Improved `ConsoleLogger` to support running in watcher.
# v3.1.38 - 2024-08-29
## Added

View File

@ -31,7 +31,13 @@ class ConsoleLogger extends SymfonyConsoleLogger implements StdoutLoggerInterfac
in_array('-vvv', $argv) => OutputInterface::VERBOSITY_DEBUG,
in_array('-vv', $argv) => OutputInterface::VERBOSITY_VERY_VERBOSE,
in_array('-v', $argv) => OutputInterface::VERBOSITY_VERBOSE,
default => match ((int) getenv('SHELL_VERBOSITY')) {
-1 => OutputInterface::VERBOSITY_QUIET,
1 => OutputInterface::VERBOSITY_VERBOSE,
2 => OutputInterface::VERBOSITY_VERY_VERBOSE,
3 => OutputInterface::VERBOSITY_DEBUG,
default => OutputInterface::VERBOSITY_NORMAL,
},
};
})()
);

View File

@ -125,13 +125,18 @@ class Watcher
$this->channel->pop();
$this->output->writeln('Start server ...');
$descriptorspec = [
$descriptorSpec = [
0 => STDIN,
1 => STDOUT,
2 => STDERR,
];
proc_open($this->option->getBin() . ' ' . BASE_PATH . '/' . $this->option->getCommand(), $descriptorspec, $pipes);
proc_open(
$this->option->getBin() . ' ' . BASE_PATH . '/' . $this->option->getCommand(),
$descriptorSpec,
$pipes,
env_vars: $_ENV
);
$this->output->writeln('Stop server success.');
$this->channel->push(1);