Skip to content

Commit

Permalink
Merge pull request #8 from pxlrbt/master
Browse files Browse the repository at this point in the history
Rename argument "--tail" to "--follow"
  • Loading branch information
taylorotwell authored Aug 3, 2021
2 parents b2414b1 + 132bec7 commit 52604a4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ You may also view logs directly from the command-line. To do so, use the `{resou

```bash
forge daemon:logs
forge daemon:logs --tail # Visualize logs in realtime
forge daemon:logs --follow # Visualize logs in realtime

forge database:logs

Expand Down
18 changes: 9 additions & 9 deletions app/Commands/Concerns/InteractsWithLogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ protected function showLogs($type)
* Shows the given site logs.
*
* @param \Laravel\Forge\Resources\Site $site
* @param bool $tail
* @param bool $follow
* @return void
*/
protected function showSiteLogs($site, $tail)
protected function showSiteLogs($site, $follow)
{
$this->step('Retrieving the latest site logs');

Expand All @@ -49,40 +49,40 @@ protected function showSiteLogs($site, $tail)

$this->showRemoteLogs(collect($files)->map(function ($file) use ($sitePath) {
return $sitePath.'/'.$file;
})->all(), $tail);
})->all(), $follow);
}

/**
* Shows the given daemon logs.
*
* @param string|int $daemonId
* @param string $username
* @param bool $tail
* @param bool $follow
* @return void
*/
protected function showDaemonLogs($daemonId, $username, $tail)
protected function showDaemonLogs($daemonId, $username, $follow)
{
abort_if($username == 'root', 1, 'Requesting logs from daemons run by [root] is not supported.');

$this->step('Retrieving the latest daemon logs');

$this->showRemoteLogs('/home/'.$username.'/.forge/daemon-'.$daemonId.'.log', $tail);
$this->showRemoteLogs('/home/'.$username.'/.forge/daemon-'.$daemonId.'.log', $follow);
}

/**
* Shows remote logs.
*
* @param array|string $files
* @param bool $tail
* @param bool $follow
* @return void
*/
protected function showRemoteLogs($files, $tail)
protected function showRemoteLogs($files, $follow)
{
$this->newLine();

[$exitCode, $output] = $this->remote->tail($files, function ($output) {
$this->displayLogs($output);
}, $tail ? ['-f'] : []);
}, $follow ? ['-f'] : []);

abort_if(
empty($output) || ($exitCode > 0 && $exitCode < 255),
Expand Down
4 changes: 2 additions & 2 deletions app/Commands/DaemonLogsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DaemonLogsCommand extends Command
* @var string
*/
protected $signature = 'daemon:logs {daemon? : The daemon ID}
` {--tail : Monitor the log changes in realtime}';
` {--f|follow : Monitor the log changes in realtime}';

/**
* The description of the command.
Expand All @@ -32,6 +32,6 @@ public function handle()

$daemon = $this->forge->daemon($this->currentServer()->id, $daemonId);

$this->showDaemonLogs($daemon->id, $daemon->user, $this->option('tail'));
$this->showDaemonLogs($daemon->id, $daemon->user, $this->option('follow'));
}
}
4 changes: 2 additions & 2 deletions app/Commands/SiteLogsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class SiteLogsCommand extends Command
* @var string
*/
protected $signature = 'site:logs {site? : The site name}
{--tail : Monitor the log changes in realtime}';
{--f|follow : Monitor the log changes in realtime}';

/**
* The description of the command.
Expand All @@ -32,6 +32,6 @@ public function handle()

$site = $this->forge->site($this->currentServer()->id, $siteId);

$this->showSiteLogs($site, $this->option('tail'));
$this->showSiteLogs($site, $this->option('follow'));
}
}
6 changes: 3 additions & 3 deletions tests/Feature/DaemonLogsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
'[00:02] BAR',
]]);

$this->artisan('daemon:logs', ['--tail' => true])
$this->artisan('daemon:logs', ['--follow' => true])
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Daemon Would You Like To Retrieve The Logs From</>', 1);
});

Expand All @@ -74,7 +74,7 @@
'[00:02] BAR',
]]);

$this->artisan('daemon:logs', ['--tail' => true])
$this->artisan('daemon:logs', ['--follow' => true])
->assertExitCode(0)
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Daemon Would You Like To Retrieve The Logs From</>', 1);
});
Expand All @@ -98,7 +98,7 @@
->with('/home/forge/.forge/daemon-1.log', Mockery::type(Closure::class), ['-f'])
->andReturn(1);

$this->artisan('daemon:logs', ['--tail' => true])
$this->artisan('daemon:logs', ['--follow' => true])
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Daemon Would You Like To Retrieve The Logs From</>', 1);
})->throws('The requested logs could not be found or they are empty.');

Expand Down
6 changes: 3 additions & 3 deletions tests/Feature/SiteLogsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
'[00:02] BAR',
]]);

$this->artisan('site:logs', ['--tail' => true])
$this->artisan('site:logs', ['--follow' => true])
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Site Would You Like To Retrieve The Logs From</>', 1);
});

Expand Down Expand Up @@ -89,7 +89,7 @@
'[00:02] BAR',
]]);

$this->artisan('site:logs', ['--tail' => true])
$this->artisan('site:logs', ['--follow' => true])
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Site Would You Like To Retrieve The Logs From</>', 1);
});

Expand Down Expand Up @@ -119,6 +119,6 @@
'ls: error',
]]);

$this->artisan('site:logs', ['--tail' => true])
$this->artisan('site:logs', ['--follow' => true])
->expectsQuestion('<fg=yellow>‣</> <options=bold>Which Site Would You Like To Retrieve The Logs From</>', 2);
})->throws('The requested logs could not be found or they are empty.');

0 comments on commit 52604a4

Please sign in to comment.