From: Vincent Vanwaelscappel Date: Wed, 3 Jul 2024 09:51:13 +0000 (+0200) Subject: wip #6986 @0.5 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=250b6406a31724c0e07171ff99f70c22e55cb952;p=cubist_util.git wip #6986 @0.5 --- diff --git a/src/CommandLine.php b/src/CommandLine.php index ebbf377..6bba3eb 100644 --- a/src/CommandLine.php +++ b/src/CommandLine.php @@ -3,6 +3,7 @@ namespace Cubist\Util; use Cubist\Net\SSH2; +use Illuminate\Contracts\Foundation\Application; use Illuminate\Support\Facades\Log; class CommandLine @@ -125,23 +126,24 @@ class CommandLine $startTime = microtime(true); $this->_preExecute(); + $measure = app() instanceof Application && function_exists('start_measure') && function_exists('stop_measure'); if ($fonction instanceof SSH2) { $this->makeCommande(); - if (function_exists('start_measure')) { + if ($measure) { start_measure('Exec CLI : ' . $this->commande); } $o = $fonction->exec($this->commande); - if (function_exists('stop_measure')) { + if ($measure) { stop_measure('Exec CLI : ' . $this->commande); } file_put_contents($this->output, $o['output'] . "\n\n---\n\n" . $o['error']); } else if (null === $this->ssh) { $this->makeCommande($this->output, $this->error); - if (function_exists('start_measure')) { + if ($measure) { start_measure('Exec CLI : ' . $this->commande); } $fonction($this->commande); - if (function_exists('stop_measure')) { + if ($measure) { stop_measure('Exec CLI : ' . $this->commande); } } else { @@ -159,11 +161,12 @@ class CommandLine } $this->commande = $c; - if (function_exists('start_measure')) { + + if ($measure) { start_measure('Exec CLI : ' . $this->commande); } $fonction($c); - if (function_exists('stop_measure')) { + if ($measure) { stop_measure('Exec CLI : ' . $this->commande); } }