Skip to content

Commit

Permalink
Merge pull request #12 from pantheon-systems/progress-option
Browse files Browse the repository at this point in the history
Only suppress output if --progress is not passed
  • Loading branch information
iamstoick authored May 14, 2024
2 parents 6cf5132 + 070c7b3 commit 0df5272
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Commands/SiteLogsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,16 @@ public function __construct()
*
* @usage <site>.<env> [dest]
*
* @option progress Show the progress of the download.
*
* To get all the logs - including archived logs.
* terminus logs:get <site>.<env> --all
*
* To store logs in a custom location.
* terminus logs:get <site>.<env> [/path/to/folder]
*/
public function GetLogs($site_env, $dest = null,
$options = ['exclude' => true, 'all' => false, 'nginx-access' => false, 'nginx-error' => false, 'php-fpm-error' => false, 'php-slow' => false, 'pyinotify' => false, 'watcher' => false, 'newrelic' => true,]) {
$options = ['exclude' => true, 'all' => false, 'nginx-access' => false, 'nginx-error' => false, 'php-fpm-error' => false, 'php-slow' => false, 'pyinotify' => false, 'watcher' => false, 'newrelic' => true, 'progress' => false]) {

// Create the logs directory if not present.
if (!is_dir($this->logPath))
Expand All @@ -112,6 +114,13 @@ public function GetLogs($site_env, $dest = null,
$src = "$env_id.$site_id";
$files = '*.log';

// only send output to /dev/null if the --progress option wasn't passed
$devnull = '>/dev/null 2>&1';
if ($options['progress'])
{
$devnull = '';
}

// If the destination parameter is empty, set destination to ~/.terminus/site-logs/[sitename]/[env]/.
if (!$dest)
{
Expand Down Expand Up @@ -141,13 +150,13 @@ public function GetLogs($site_env, $dest = null,
if ($options['all'])
{
$this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsync_options $src@$app_server_ip:logs/* $dir"]);
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/* $dir >/dev/null 2>&1");
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/* $dir $devnull");
}
else
{
$this->log()->notice('Running {cmd}', ['cmd' => "rsync $rsync_options $src@$app_server_ip:logs/ $dir"]);
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/nginx/* $dir >/dev/null 2>&1");
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/php/* $dir >/dev/null 2>&1");
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/nginx/* $dir $devnull");
$this->passthru("rsync $rsync_options -zi --progress --ipv4 --exclude=.git -e 'ssh -p 2222' $src@$app_server_ip:logs/php/* $dir $devnull");
}
}

Expand Down

0 comments on commit 0df5272

Please sign in to comment.