mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 08:30:07 +01:00
Resolutions to the following change requests:
- https://github.com/laravel/valet/pull/757#discussion_r274547618 - https://github.com/laravel/valet/pull/757#discussion_r274549378 - https://github.com/laravel/valet/pull/757#discussion_r274549637 - https://github.com/laravel/valet/pull/757#discussion_r274549735 - https://github.com/laravel/valet/pull/757#discussion_r274550184 - https://github.com/laravel/valet/pull/757#discussion_r274550266 - https://github.com/laravel/valet/pull/757#discussion_r274550513 - https://github.com/laravel/valet/pull/757#discussion_r274550683 - https://github.com/laravel/valet/pull/757#discussion_r274550831 - https://github.com/laravel/valet/pull/757#discussion_r274550915 - https://github.com/laravel/valet/pull/757#discussion_r274551027
This commit is contained in:
@@ -291,7 +291,7 @@
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tail log files.
|
||||
* Tail log file.
|
||||
*/
|
||||
$app->command('logs [-f|--follow] [-l|--lines=] [key]', function ($follow, $lines, $key = null) {
|
||||
$defaultLogs = [
|
||||
@@ -304,46 +304,60 @@
|
||||
];
|
||||
|
||||
$configLogs = data_get(Configuration::read(), 'logs');
|
||||
if (!is_array($configLogs)) $configLogs = [];
|
||||
if (! is_array($configLogs)) {
|
||||
$configLogs = [];
|
||||
}
|
||||
|
||||
$logs = collect(array_merge($defaultLogs, $configLogs))->sortKeys();
|
||||
|
||||
if (!$key) {
|
||||
if (! $key) {
|
||||
info(implode(PHP_EOL, [
|
||||
'Here are the logs you might be interested in.',
|
||||
null,
|
||||
'In order to tail a log, pass the relevant log key (e.g. "php")',
|
||||
'In order to tail a log, pass the relevant log key (e.g. "nginx")',
|
||||
'along with any optional tail parameters (e.g. "-f" for follow).',
|
||||
null,
|
||||
'For example: "valet logs php -f --lines=3"',
|
||||
'For example: "valet logs nginx -f --lines=3"',
|
||||
null,
|
||||
'Here are the logs you might be interested in.',
|
||||
null,
|
||||
]));
|
||||
|
||||
table(
|
||||
['Keys', 'Files'],
|
||||
collect($logs)->map(function ($file, $key) {
|
||||
return [$key, $file];
|
||||
})->toArray()
|
||||
);
|
||||
|
||||
info(implode(PHP_EOL, [
|
||||
null,
|
||||
'Tip: Set custom logs by adding a "logs" key/file object',
|
||||
'to your "'.Configuration::path().'" file.',
|
||||
]));
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!isset($logs[$key])) return warning('No logs found for ['.$key.'].');
|
||||
if (! isset($logs[$key])) {
|
||||
return warning('No logs found for ['.$key.'].');
|
||||
}
|
||||
|
||||
$file = $logs[$key];
|
||||
if (!file_exists($file)) return warning('Log path ['.$file.'] does not (yet) exist.');
|
||||
if (! file_exists($file)) {
|
||||
return warning('Log path ['.$file.'] does not (yet) exist.');
|
||||
}
|
||||
|
||||
$options = [];
|
||||
if ($follow) $options[] = '-f';
|
||||
if ((int) $lines) $options[] = '-n '.(int) $lines;
|
||||
if ($follow) {
|
||||
$options[] = '-f';
|
||||
}
|
||||
if ((int) $lines) {
|
||||
$options[] = '-n '.(int) $lines;
|
||||
}
|
||||
|
||||
$command = implode(' ', array_merge(['tail'], $options, [$file]));
|
||||
|
||||
passthru($command);
|
||||
})->descriptions('Tail log files');
|
||||
})->descriptions('Tail log file');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user