1
0
mirror of https://github.com/laravel/valet.git synced 2026-02-06 16:50:09 +01:00

Adds the option to view the Caddy access- and error-log using 'valet server-log'

This commit is contained in:
Jan Willem Kaper
2016-06-15 22:57:58 +02:00
parent d4e71e51db
commit 4fc1acb7c4
4 changed files with 62 additions and 0 deletions

View File

@@ -27,6 +27,7 @@ function install()
$this->createDriversDirectory();
$this->createSitesDirectory();
$this->createExtensionsDirectory();
$this->createLogDirectory();
$this->writeBaseConfiguration();
$this->files->chown($this->path(), user());
@@ -81,6 +82,18 @@ function createExtensionsDirectory()
$this->files->ensureDirExists(VALET_HOME_PATH.'/Extensions', user());
}
/**
* Create the directory for Caddy log.
*
* @return void
*/
function createLogDirectory()
{
$this->files->ensureDirExists(VALET_HOME_PATH.'/Log', user());
$this->files->touch(VALET_HOME_PATH.'/Log/access.log');
$this->files->touch(VALET_HOME_PATH.'/Log/error.log');
}
/**
* Write the base, initial configuration for Valet.
*/

View File

@@ -8,4 +8,20 @@ import VALET_HOME_PATH/Caddy/*
rewrite {
to /server.php?{query}
}
log VALET_HOME_PATH/Log/access.log {
rotate {
size 10
age 3
keep 1
}
}
errors {
log VALET_HOME_PATH/Log/error.log {
size 10
age 3
keep 1
}
}
}

View File

@@ -12,4 +12,20 @@ https://VALET_SITE:443 {
rewrite {
to /server.php?{query}
}
log VALET_HOME_PATH/Log/access.log {
rotate {
size 10
age 3
keep 1
}
}
errors {
log VALET_HOME_PATH/Log/error.log {
size 10
age 3
keep 1
}
}
}

View File

@@ -172,6 +172,23 @@
}
})->descriptions('Stream all of the logs for all Laravel sites registered with Valet');
/**
* Stream Caddy access- and error-log.
*/
$app->command('server-log', function () {
$files = Filesystem::scandir(VALET_HOME_PATH.'/Log');
$files = collect($files)->transform(function ($file) {
return escapeshellarg(VALET_HOME_PATH.'/Log/'.$file);
})->all();
if (count($files) > 0) {
passthru('tail -f '.implode(' ', $files));
} else {
warning('No log files were found.');
}
})->descriptions('Stream Caddy access- and error-log.');
/**
* Display all of the registered paths.
*/