mirror of
https://github.com/laravel/valet.git
synced 2026-02-05 16:40:05 +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) {
|
$app->command('logs [-f|--follow] [-l|--lines=] [key]', function ($follow, $lines, $key = null) {
|
||||||
$defaultLogs = [
|
$defaultLogs = [
|
||||||
@@ -304,46 +304,60 @@
|
|||||||
];
|
];
|
||||||
|
|
||||||
$configLogs = data_get(Configuration::read(), 'logs');
|
$configLogs = data_get(Configuration::read(), 'logs');
|
||||||
if (!is_array($configLogs)) $configLogs = [];
|
if (! is_array($configLogs)) {
|
||||||
|
$configLogs = [];
|
||||||
|
}
|
||||||
|
|
||||||
$logs = collect(array_merge($defaultLogs, $configLogs))->sortKeys();
|
$logs = collect(array_merge($defaultLogs, $configLogs))->sortKeys();
|
||||||
|
|
||||||
if (! $key) {
|
if (! $key) {
|
||||||
info(implode(PHP_EOL, [
|
info(implode(PHP_EOL, [
|
||||||
'Here are the logs you might be interested in.',
|
'In order to tail a log, pass the relevant log key (e.g. "nginx")',
|
||||||
null,
|
|
||||||
'In order to tail a log, pass the relevant log key (e.g. "php")',
|
|
||||||
'along with any optional tail parameters (e.g. "-f" for follow).',
|
'along with any optional tail parameters (e.g. "-f" for follow).',
|
||||||
null,
|
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,
|
null,
|
||||||
]));
|
]));
|
||||||
|
|
||||||
table(
|
table(
|
||||||
['Keys', 'Files'],
|
['Keys', 'Files'],
|
||||||
collect($logs)->map(function ($file, $key) {
|
collect($logs)->map(function ($file, $key) {
|
||||||
return [$key, $file];
|
return [$key, $file];
|
||||||
})->toArray()
|
})->toArray()
|
||||||
);
|
);
|
||||||
|
|
||||||
info(implode(PHP_EOL, [
|
info(implode(PHP_EOL, [
|
||||||
null,
|
null,
|
||||||
'Tip: Set custom logs by adding a "logs" key/file object',
|
'Tip: Set custom logs by adding a "logs" key/file object',
|
||||||
'to your "'.Configuration::path().'" file.',
|
'to your "'.Configuration::path().'" file.',
|
||||||
]));
|
]));
|
||||||
|
|
||||||
exit;
|
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];
|
$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 = [];
|
$options = [];
|
||||||
if ($follow) $options[] = '-f';
|
if ($follow) {
|
||||||
if ((int) $lines) $options[] = '-n '.(int) $lines;
|
$options[] = '-f';
|
||||||
|
}
|
||||||
|
if ((int) $lines) {
|
||||||
|
$options[] = '-n '.(int) $lines;
|
||||||
|
}
|
||||||
|
|
||||||
$command = implode(' ', array_merge(['tail'], $options, [$file]));
|
$command = implode(' ', array_merge(['tail'], $options, [$file]));
|
||||||
|
|
||||||
passthru($command);
|
passthru($command);
|
||||||
})->descriptions('Tail log files');
|
})->descriptions('Tail log file');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user