Additional logging for the stats recalculation (#358)

* Additional logging for the stats recalculation

* style fix
This commit is contained in:
Nabeel S
2019-08-10 20:42:35 -04:00
committed by GitHub
parent c1103afe8f
commit dc51897314
19 changed files with 99 additions and 43 deletions

View File

@@ -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);

View File

@@ -47,6 +47,8 @@ class AcarsReplay extends Command
{
parent::__construct();
$this->redirectLoggingToFile('stdout');
$this->httpClient = new Client([
'base_uri' => config('app.url'),
'headers' => [

View File

@@ -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
*/

View File

@@ -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();
}
/**

View File

@@ -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
*/

View File

@@ -26,6 +26,8 @@ class DevInstall extends Command
public function __construct(\DatabaseSeeder $databaseSeeder)
{
parent::__construct();
$this->redirectLoggingToFile('stdout');
$this->databaseSeeder = $databaseSeeder;
}

View File

@@ -23,6 +23,8 @@ class ImportCsv extends Command
public function __construct(ImportService $importer)
{
parent::__construct();
$this->redirectLoggingToFile('stdout');
$this->importer = $importer;
}

View File

@@ -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
*

View File

@@ -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
*/

View File

@@ -18,6 +18,8 @@ class Version extends Command
public function __construct(VersionService $versionSvc)
{
parent::__construct();
$this->redirectLoggingToFile('stdout');
$this->versionSvc = $versionSvc;
}

View File

@@ -17,6 +17,8 @@ class YamlExport extends Command
public function __construct()
{
parent::__construct();
$this->redirectLoggingToFile('stdout');
}
/**

View File

@@ -22,7 +22,9 @@ class YamlImport extends Command
public function __construct(DatabaseService $dbSvc)
{
parent::__construct();
$this->dbSvc = $dbSvc;
$this->redirectLoggingToFile('stdout');
}
/**

View File

@@ -17,7 +17,7 @@ class Hourly extends Command
public function handle(): void
{
$this->redirectLoggingToStdout('cron');
$this->redirectLoggingToFile('cron');
event(new CronHourly());
}
}

View File

@@ -19,7 +19,7 @@ class Monthly extends Command
public function handle(): void
{
$this->redirectLoggingToStdout('cron');
$this->redirectLoggingToFile('cron');
event(new CronMonthly());
}
}

View File

@@ -19,7 +19,7 @@ class Nightly extends Command
public function handle(): void
{
$this->redirectLoggingToStdout('cron');
$this->redirectLoggingToFile('cron');
event(new CronNightly());
}
}

View File

@@ -19,7 +19,7 @@ class Weekly extends Command
public function handle(): void
{
$this->redirectLoggingToStdout('cron');
$this->redirectLoggingToFile('cron');
event(new CronWeekly());
}
}