From c30fd8b7f0e83347da2c51e1f051788509a95da0 Mon Sep 17 00:00:00 2001 From: Mark Friedrich Date: Fri, 22 Jun 2018 15:29:29 +0200 Subject: [PATCH] - improved error logging vor CLI (cronjob) scripts --- app/cron.ini | 4 ++-- app/main/controller/controller.php | 24 +++++++++++++++++++++++- app/main/cron/mapupdate.php | 14 +++++++------- app/main/model/universe/systemmodel.php | 1 - public/templates/dialog/credit.html | 4 ++-- public/templates/view/setup.html | 2 +- 6 files changed, 35 insertions(+), 14 deletions(-) diff --git a/app/cron.ini b/app/cron.ini index 68ebc4cb..9846d723 100644 --- a/app/cron.ini +++ b/app/cron.ini @@ -1,7 +1,7 @@ [CRON] log = TRUE cli = TRUE -web = TRUE +web = FALSE [CRON.presets] ; run every minute @@ -57,4 +57,4 @@ deleteExpiredCacheData = Cron\Cache->deleteExpiredData, @downtime deleteStatisticsData = Cron\StatisticsUpdate->deleteStatisticsData, @weekly ; setup universe DB with static data from ESI -; setup = Cron\Universe->setup, @instant \ No newline at end of file +setup = Cron\Universe->setup, @instant \ No newline at end of file diff --git a/app/main/controller/controller.php b/app/main/controller/controller.php index 8f3fe943..6d1e029a 100644 --- a/app/main/controller/controller.php +++ b/app/main/controller/controller.php @@ -597,6 +597,24 @@ class Controller { return $userAgent; } + /** + * print error information in CLI mode + * @param \stdClass $error + */ + protected function echoErrorCLI(\stdClass $error){ + echo '[' . date('H:i:s') . '] ───────────────────────────' . PHP_EOL; + foreach(get_object_vars($error) as $key => $value){ + $row = str_pad(' ',2 ) . str_pad($key . ':',10 ); + if($key == 'trace'){ + $value = preg_replace("/\r\n|\r|\n/", "\n" . str_pad(' ',12 ), $value); + $row .= PHP_EOL . str_pad(' ',12 ) . $value; + }else{ + $row .= $value; + } + echo $row . PHP_EOL; + } + } + /** * onError() callback function * -> on AJAX request -> return JSON with error information @@ -631,7 +649,11 @@ class Controller { $f3->status($error->code); } - if($f3->get('AJAX')){ + if($f3->get('CLI')){ + $this->echoErrorCLI($error); + // no further processing (no HTML output) + return false; + }elseif($f3->get('AJAX')){ $return = (object) []; $return->error[] = $error; echo json_encode($return); diff --git a/app/main/cron/mapupdate.php b/app/main/cron/mapupdate.php index 313816f8..19e8e79d 100644 --- a/app/main/cron/mapupdate.php +++ b/app/main/cron/mapupdate.php @@ -187,13 +187,13 @@ class MapUpdate extends AbstractCron { $pfDB = DB\Database::instance()->getDB('PF'); if($pfDB){ $sqlDeleteExpiredSignatures = "DELETE `sigs` FROM - `system_signature` `sigs` INNER JOIN - `system` ON - `system`.`id` = `sigs`.`systemId` - WHERE - `system`.`active` = 0 AND - TIMESTAMPDIFF(SECOND, `sigs`.`updated`, NOW() ) > :lifetime - "; + `system_signature` `sigs` INNER JOIN + `system` ON + `system`.`id` = `sigs`.`systemId` + WHERE + `system`.`active` = 0 AND + TIMESTAMPDIFF(SECOND, `sigs`.`updated`, NOW() ) > :lifetime + "; $pfDB->exec($sqlDeleteExpiredSignatures, ['lifetime' => $signatureExpire]); } diff --git a/app/main/model/universe/systemmodel.php b/app/main/model/universe/systemmodel.php index de81396c..3652e48a 100644 --- a/app/main/model/universe/systemmodel.php +++ b/app/main/model/universe/systemmodel.php @@ -226,7 +226,6 @@ class SystemModel extends BasicUniverseModel { * return false will stop any further action * @param self $self * @param $pkeys - * @throws \Exception\ValidationException */ public function afterUpdateEvent($self, $pkeys){ $staticNames = (array)$self->staticNames; diff --git a/public/templates/dialog/credit.html b/public/templates/dialog/credit.html index bb8a1b01..b8bc4495 100644 --- a/public/templates/dialog/credit.html +++ b/public/templates/dialog/credit.html @@ -47,12 +47,12 @@
diff --git a/public/templates/view/setup.html b/public/templates/view/setup.html index 69941729..4f9de89b 100644 --- a/public/templates/view/setup.html +++ b/public/templates/view/setup.html @@ -928,7 +928,7 @@
- + {{ @indexData.countBuild }}/{{ @indexData.countAll }}