2014-12-22 11 views

risposta

17

C'è la funzione getVerbosity() in Symfony\Component\Console\Output\OutputInterface ed è possibile utilizzare $this->getOutput() per recuperare l'oggetto di output.

$verbosityLevel = $this->getOutput()->getVerbosity(); 

È quindi possibile confrontare il livello alle costanti definite all'interno OutputInterface. Ad esempio:

if($verbosityLevel >= OutputInterface::VERBOSITY_VERBOSE){ 
    // show verbose messages 
} 
+3

Bello! Darò un giro. Ho anche scoperto che $ this-> option ('verbose') funziona per darti un semplice booleano. (Non copre -v vs -vvv, comunque) – Anthony

+0

Cool non sapeva di 'opzione ('verbose')' – lukasgeiter

+3

Si potrebbe anche usare '$ this-> output-> isVerbose()' [api.symfony. com/3,1/...] (http://api.symfony.com/3.1/Symfony/Component/Console/Output/OutputInterface.html#method_isVerbose). 'isVerbose()' è '-v',' isVeryVerbose() 'è' -vv', 'isDebug()' è '-vvv'. – bzeaman

Problemi correlati