- new "logging" system for map/system/signature/connection changes, closed #271

- new map change log to Slack channel
- new "rally point" logging to Slack channel
- new "rally point" poke options (e.g. custom message), closed #295
- new log options for WebSocket installations
- added ship "mass" logging (backend only), #313
- added map logging to Slack, #326
- added "ESI error rate" limit detection
- added "Monolog" as new logging library (Composer dependency)
- added "Swiftmailer" as new eMail library (Composer dependency)
- added Support for Redis session hander (performance boost)
- improved character select panels (visible "online" status)
- improved "activity logging" (more DB columns added to check)
- improved eMail logging (HTML template support)
- improved "delete map" now become "inactive" for some days before delete
- improved character logout handling
- improved /setup page for DB bootstrap (new button for DB create if not exists)
- fixed broken ship tracking (ship name re-added)
- fixed broken ship tracking for multiple chars on different browser tabs
- fixed broken cursor coordinates, closed #518
- fixed null pointer "charactermodel.php->isActive():925" closed #529
- fixed broken "scroll offset", closed #533 closed #534
- Updated "validation" library JS v0.10.1 -> v0.11.9
- Updated ORM Mapper _Cortex_ v1.5.0-dev -> v1.5.0
- and many more....
This commit is contained in:
Exodus4D
2017-10-22 17:58:33 +02:00
parent d00e550972
commit a8edf39697
235 changed files with 10571 additions and 3515 deletions

View File

@@ -8,42 +8,73 @@
namespace controller;
use DB;
use lib\Config;
use Lib\Logging\MapLog;
use Model\ActivityLogModel;
use Model\BasicModel;
class LogController extends \Prefab {
const CACHE_KEY_ACTIVITY_COLUMNS = 'CACHED_ACTIVITY_COLUMNS';
const CACHE_TTL_ACTIVITY_COLUMNS = 300;
/**
* @var string[]
*/
protected $activityLogColumns = [];
/**
* buffered activity log data for this singleton LogController() class
* -> this buffered data can be stored somewhere (e.g. DB) before HTTP response
* -> should be cleared afterwards!
* @var array
*/
protected $activityLogBuffer = [];
protected $activityLogBuffer = [];
/**
* reserve a "new" character activity for logging
* @param $characterId
* @param $mapId
* @param $action
* get columns from ActivityLogModel that can be uses as counter
* @return array
*/
public function bufferActivity($characterId, $mapId, $action){
$characterId = (int)$characterId;
$mapId = (int)$mapId;
protected function getActivityLogColumns(): array{
if(empty($this->activityLogColumns)){
$f3 = \Base::instance();
if(!$f3->exists(self::CACHE_KEY_ACTIVITY_COLUMNS, $this->activityLogColumns)){
/**
* @var $activityLogModel ActivityLogModel
*/
$activityLogModel = BasicModel::getNew('ActivityLogModel');
$this->activityLogColumns = $activityLogModel->getCountableColumnNames();
$f3->set(self::CACHE_KEY_ACTIVITY_COLUMNS, self::CACHE_TTL_ACTIVITY_COLUMNS);
}
}
if(
$characterId > 0 &&
$mapId > 0
){
$key = $this->getBufferedActivityKey($characterId, $mapId);
return $this->activityLogColumns;
}
if( is_null($key) ){
$activity = [
'characterId' => $characterId,
'mapId' => $mapId,
$action => 1
];
$this->activityLogBuffer[] = $activity;
}else{
$this->activityLogBuffer[$key][$action]++;
/**
* buffered activity log data for this singleton LogController() class
* -> this buffered data can be stored somewhere (e.g. DB) before HTTP response
* -> should be cleared afterwards!
* @param MapLog $log
*/
public function push(MapLog $log){
$action = $log->getAction();
// check $action to be valid (table column exists)
if($action && in_array($action, $this->getActivityLogColumns())){
if($mapId = $log->getChannelId()){
$logData = $log->getData();
if($characterId = (int)$logData['character']['id']){
if($index = $this->getBufferedActivityIndex($characterId, $mapId)){
$this->activityLogBuffer[$index][$action]++;
}else{
$this->activityLogBuffer[] = [
'characterId' => $characterId,
'mapId' => $mapId,
$action => 1
];
}
}
}
}
}
@@ -51,7 +82,7 @@ class LogController extends \Prefab {
/**
* store all buffered activity log data to DB
*/
public function storeActivities(){
public function logActivities(){
if( !empty($this->activityLogBuffer) ){
$db = DB\Database::instance()->getDB('PF');
@@ -104,24 +135,20 @@ class LogController extends \Prefab {
}
/**
* get array key from "buffered activity log" array
* get array key/index from "buffered activity log" array
* @param int $characterId
* @param int $mapId
* @return int|null
* @return int
*/
private function getBufferedActivityKey($characterId, $mapId){
$activityKey = null;
if(
$characterId > 0 &&
$mapId > 0
){
private function getBufferedActivityIndex(int $characterId, int $mapId): int {
$activityKey = 0;
if($characterId > 0 && $mapId > 0 ){
foreach($this->activityLogBuffer as $key => $activityData){
if(
$activityData['characterId'] === $characterId &&
$activityData['mapId'] === $mapId
){
$activityKey = $key;
$activityKey = (int)$key;
break;
}
}
@@ -136,8 +163,7 @@ class LogController extends \Prefab {
* @return \Log|null
*/
public static function getLogger($type){
$f3 = \Base::instance();
$logFiles = $f3->get('PATHFINDER.LOGFILES');
$logFiles = Config::getPathfinderData('logfiles');
$logFileName = empty($logFiles[$type]) ? 'error' : $logFiles[$type];
$logFile = $logFileName . '.log';