mirror of
https://github.com/laravel/valet.git
synced 2026-02-06 00:40:06 +01:00
Added "logs" command (with optional "follow" and "lines" flags), defaulting to Valet's "/log/nginx-error.log" file if no "logs.[file]" configuration value is found in Valet's "config.json" file.
This commit is contained in:
@@ -289,6 +289,28 @@
|
||||
})->descriptions('Change the version of php used by valet', [
|
||||
'phpVersion' => 'The PHP version you want to use, e.g php@7.2',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Tail log file.
|
||||
*/
|
||||
$app->command('logs [-f|--follow] [--lines=] [file]', function ($follow, $lines, $file = null) {
|
||||
$defaultLogFile = VALET_HOME_PATH.'/Log/nginx-error.log';
|
||||
|
||||
$logFile = data_get(Configuration::read(), "logs.$file", $defaultLogFile);
|
||||
|
||||
$options = [];
|
||||
|
||||
if ($follow) $options[] = '-f';
|
||||
|
||||
if ((int) $lines) {
|
||||
$options[] = '-n';
|
||||
$options[] = (int) $lines;
|
||||
}
|
||||
|
||||
$logCommand = implode(' ', array_merge(['tail'], $options, [$logFile]));
|
||||
|
||||
passthru($logCommand);
|
||||
})->descriptions('Tail log file');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user