Update logs layout

This commit is contained in:
2019-10-06 10:14:57 +02:00
parent 956f6c7022
commit 8e0f4a8a12
6 changed files with 22 additions and 458 deletions

View File

@@ -19,7 +19,7 @@ class ClassManagement extends PhpObject
function __construct($sMainClass)
{
parent::__construct(__CLASS__, true);
parent::__construct(__FILE__, true);
$this->asIncFiles = array();
//try to include default files
@@ -155,14 +155,21 @@ class PhpObject
private function addMessage($sType, $sMessage)
{
$this->asMessageStack[$sType][] = $sMessage;
$this->asMessageStack[$sType][] = array('msg'=>$sMessage, 'time'=>date('d.m.Y H:i:s'), 'type'=>$sType, 'location'=>$this->sChildClass);
}
protected function getCleanMessageStack($sType=self::ALL_TAB)
{
$asMessages = ($sType==self::ALL_TAB)?$this->asMessageStack:$this->asMessageStack[$sType];
if($sType==self::ALL_TAB) {
$asMessages = array_merge( //No overlap, numeric keys
$this->asMessageStack[self::NOTICE_TAB],
$this->asMessageStack[self::WARNING_TAB],
$this->asMessageStack[self::ERROR_TAB]
);
}
else $asMessages = $this->asMessageStack[$sType];
$this->resetMessageStack($sType);
return $this->glueMessages($asMessages);
}
@@ -182,12 +189,13 @@ class PhpObject
case self::MODE_ARRAY:
break;
case self::MODE_FILE:
@file_put_contents(self::getLogPath(), "\n\n".$this->sChildClass.' - '.date('r')."\n".$sErrorStack, FILE_APPEND);
@file_put_contents(self::getLogPath(), "\n".$sErrorStack, FILE_APPEND);
break;
}
}
}
/*
protected function getCleanMessageStacks($aoExtsources, $sType=self::ALL_TAB)
{
$aoExtsources[] = $this;
@@ -202,7 +210,8 @@ class PhpObject
}
return $this->glueMessages($aoMessages);
}
*/
private function glueMessages($asMessages)
{
switch($this->iExtractMode)
@@ -223,20 +232,11 @@ class PhpObject
return $oMessageStack;
}
private static function flattenMessageStack($asTab, $sGlobalKey='')
private static function flattenMessageStack($asTab)
{
$asFlatTab = array();
foreach($asTab as $oKey=>$oRow)
{
$sKey = is_numeric($oKey)?$sGlobalKey:$oKey.' - ';
if(is_array($oRow))
{
$asFlatTab = array_merge($asFlatTab, self::flattenMessageStack($oRow, $sKey));
}
else
{
$asFlatTab[] = $sKey.$oRow;
}
foreach($asTab as $asRow) {
$asFlatTab[] = '['.$asRow['time'].'] '.$asRow['type'].' - '.$asRow['location'].' - '.$asRow['msg'];
}
return $asFlatTab;
}