Ant*_*ony 16 verbosity laravel artisan
有没有办法检测用户在创建自定义工匠命令时指定的详细级别?我在文档中没有看到任何关于它的内容.
luk*_*ter 25
有getVerbosity()功能,Symfony\Component\Console\Output\OutputInterface您可以使用它$this->getOutput()来检索输出对象.
$verbosityLevel = $this->getOutput()->getVerbosity();
Run Code Online (Sandbox Code Playgroud)
然后,您可以将级别与内部定义的常量进行比较OutputInterface.例如:
if($verbosityLevel >= OutputInterface::VERBOSITY_VERBOSE){
// show verbose messages
}
Run Code Online (Sandbox Code Playgroud)
小智 8
您可以根据文档使用不同的详细程度:
https://laravel.com/api/5.6/Illuminate/Console/OutputStyle.html#method_isQuiet
isQuiet() - no verbosity is set (no option set)
isVerbose() - if the level is quiet or verbose (-v)
isVeryVerbose() - if the level is very verbose, verbose or quiet (-vv)
isDebug() - if the level is debug, very verbose, verbose or quiet (-vvv)
Run Code Online (Sandbox Code Playgroud)
例如在您的命令中 $this->getOutput()->isQuiet()
这也会影响writeLn()。如果要编写$this->line('Serious message', null, 'vv');,则消息将显示为-vv和-vvv选项,但不会显示为和-v静默模式,因为对于那些级别的日志记录,该消息“太详细”。
| 归档时间: |
|
| 查看次数: |
5663 次 |
| 最近记录: |