Additional logging for the stats recalculation (#358)
* Additional logging for the stats recalculation * style fix
This commit is contained in:
@@ -16,15 +16,12 @@ abstract class Command extends \Illuminate\Console\Command
|
||||
abstract public function handle();
|
||||
|
||||
/**
|
||||
* Splice the logger and replace the active handlers with
|
||||
* the handlers from the "cron" stack in config/logging.php
|
||||
* Splice the logger and replace the active handlers with the handlers from the
|
||||
* a stack in config/logging.php
|
||||
*
|
||||
* Close out any of the existing handlers so we don't leave
|
||||
* file descriptors leaking around
|
||||
*
|
||||
* @param string $channel_name Channel name to grab the handlers from
|
||||
* @param string $channel_name Channel name from config/logging.php
|
||||
*/
|
||||
public function redirectLoggingToStdout($channel_name): void
|
||||
public function redirectLoggingToFile($channel_name): void
|
||||
{
|
||||
$logger = app(\Illuminate\Log\Logger::class);
|
||||
|
||||
|
||||
@@ -47,6 +47,8 @@ class AcarsReplay extends Command
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
|
||||
$this->httpClient = new Client([
|
||||
'base_uri' => config('app.url'),
|
||||
'headers' => [
|
||||
|
||||
@@ -13,6 +13,13 @@ class ComposerCommand extends Command
|
||||
protected $signature = 'phpvms:composer {cmd}';
|
||||
protected $description = 'Composer related tasks';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run composer update related commands
|
||||
*/
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands;
|
||||
|
||||
use App\Console\Command;
|
||||
use Log;
|
||||
use Tivie\OS\Detector;
|
||||
|
||||
/**
|
||||
* Class CreateDatabase
|
||||
@@ -20,7 +21,9 @@ class CreateDatabase extends Command
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->os = new \Tivie\OS\Detector();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
$this->os = new Detector();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Repositories\AcarsRepository;
|
||||
use App\Services\AirportService;
|
||||
use App\Services\AwardService;
|
||||
use App\Services\DatabaseService;
|
||||
use App\Services\UserService;
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\Artisan;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -35,6 +36,8 @@ class DevCommands extends Command
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
$this->dbSvc = $dbSvc;
|
||||
}
|
||||
|
||||
@@ -51,16 +54,17 @@ class DevCommands extends Command
|
||||
}
|
||||
|
||||
$commands = [
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'live-flights' => 'liveFlights',
|
||||
'manual-insert' => 'manualInsert',
|
||||
'metar' => 'getMetar',
|
||||
'reset-install' => 'resetInstall',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
'clear-acars' => 'clearAcars',
|
||||
'clear-users' => 'clearUsers',
|
||||
'compile-assets' => 'compileAssets',
|
||||
'db-attrs' => 'dbAttrs',
|
||||
'list-awards' => 'listAwardClasses',
|
||||
'live-flights' => 'liveFlights',
|
||||
'manual-insert' => 'manualInsert',
|
||||
'metar' => 'getMetar',
|
||||
'recalculate-stats' => 'recalculateStats',
|
||||
'reset-install' => 'resetInstall',
|
||||
'xml-to-yaml' => 'xmlToYaml',
|
||||
];
|
||||
|
||||
if (!array_key_exists($command, $commands)) {
|
||||
@@ -234,6 +238,15 @@ class DevCommands extends Command
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculate the stats for all users
|
||||
*/
|
||||
protected function recalculateStats(): void
|
||||
{
|
||||
$userSvc = app(UserService::class);
|
||||
$userSvc->recalculateAllUserStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all of the tables, etc from the database, for a clean install
|
||||
*/
|
||||
|
||||
@@ -26,6 +26,8 @@ class DevInstall extends Command
|
||||
public function __construct(\DatabaseSeeder $databaseSeeder)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
$this->databaseSeeder = $databaseSeeder;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ class ImportCsv extends Command
|
||||
public function __construct(ImportService $importer)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
$this->importer = $importer;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,6 +14,13 @@ class NavdataImport extends Command
|
||||
protected $signature = 'phpvms:navdata';
|
||||
protected $description = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws \League\Geotools\Exception\InvalidArgumentException
|
||||
*
|
||||
|
||||
@@ -13,6 +13,12 @@ class TestApi extends Command
|
||||
protected $signature = 'phpvms:test-api {apikey} {url}';
|
||||
protected $httpClient;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run dev related commands
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@ class Version extends Command
|
||||
public function __construct(VersionService $versionSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
$this->versionSvc = $versionSvc;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ class YamlExport extends Command
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,7 +22,9 @@ class YamlImport extends Command
|
||||
public function __construct(DatabaseService $dbSvc)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->dbSvc = $dbSvc;
|
||||
$this->redirectLoggingToFile('stdout');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@ class Hourly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronHourly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Monthly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronMonthly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Nightly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronNightly());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ class Weekly extends Command
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->redirectLoggingToStdout('cron');
|
||||
$this->redirectLoggingToFile('cron');
|
||||
event(new CronWeekly());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user