diff --git a/PHPCI/Command/DaemonCommand.php b/PHPCI/Command/DaemonCommand.php index d6458f2b..3962d248 100644 --- a/PHPCI/Command/DaemonCommand.php +++ b/PHPCI/Command/DaemonCommand.php @@ -10,8 +10,10 @@ namespace PHPCI\Command; +use Monolog\Logger; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -27,6 +29,17 @@ use PHPCI\BuildFactory; */ class DaemonCommand extends Command { + /** + * @var \Monolog\Logger + */ + protected $logger; + + public function __construct(Logger $logger, $name = null) + { + parent::__construct($name); + $this->logger = $logger; + } + protected function configure() { $this @@ -68,12 +81,14 @@ class DaemonCommand extends Command if (file_exists(PHPCI_DIR.'/daemon/daemon.pid')) { echo "Already started\n"; + $this->logger->warning("Daemon already started"); return "alreadystarted"; } $logfile = PHPCI_DIR."/daemon/daemon.log"; $cmd = "nohup %s/daemonise phpci:daemonise > %s 2>&1 &"; $command = sprintf($cmd, PHPCI_DIR, $logfile); + $this->logger->info("Daemon started"); exec($command); } @@ -82,12 +97,14 @@ class DaemonCommand extends Command if (!file_exists(PHPCI_DIR.'/daemon/daemon.pid')) { echo "Not started\n"; + $this->logger->warning("Can't stop daemon as not started"); return "notstarted"; } $cmd = "kill $(cat %s/daemon/daemon.pid)"; $command = sprintf($cmd, PHPCI_DIR); exec($command); + $this->logger->info("Daemon stopped"); unlink(PHPCI_DIR.'/daemon/daemon.pid'); } @@ -110,13 +127,4 @@ class DaemonCommand extends Command echo "Not running\n"; return "notrunning"; } - - /** - * Called when log entries are made in Builder / the plugins. - * @see \PHPCI\Builder::log() - */ - public function logCallback($log) - { - $this->output->writeln($log); - } } diff --git a/PHPCI/Command/UpdateCommand.php b/PHPCI/Command/UpdateCommand.php index e5806025..855ca893 100644 --- a/PHPCI/Command/UpdateCommand.php +++ b/PHPCI/Command/UpdateCommand.php @@ -9,8 +9,10 @@ namespace PHPCI\Command; +use Monolog\Logger; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -23,6 +25,17 @@ use Symfony\Component\Console\Output\OutputInterface; */ class UpdateCommand extends Command { + /** + * @var \Monolog\Logger + */ + protected $logger; + + public function __construct(Logger $logger, $name = null) + { + parent::__construct($name); + $this->logger = $logger; + } + protected function configure() { $this diff --git a/console b/console index 7525b054..fc639be4 100755 --- a/console +++ b/console @@ -25,8 +25,8 @@ $application = new Application(); $application->add(new RunCommand($loggerConfig->GetFor('RunCommand'))); $application->add(new InstallCommand); -$application->add(new UpdateCommand); +$application->add(new UpdateCommand($loggerConfig->GetFor('UpdateCommand'))); $application->add(new GenerateCommand); -$application->add(new DaemonCommand); +$application->add(new DaemonCommand($loggerConfig->GetFor('DaemonCommand'))); $application->run();