diff --git a/public_html/deployment/classes/logger.class.php b/public_html/deployment/classes/logger.class.php index 1bc74090de16472ff21a545bcfedf28dba017615..691c92f6860e8aff5d12ef5e29a8c21f188de06e 100644 --- a/public_html/deployment/classes/logger.class.php +++ b/public_html/deployment/classes/logger.class.php @@ -29,6 +29,11 @@ class logger { return $this->bShowDebug=$bEnable; } + /** + * enable client debugging by a given array of allowed ip addresses + * @param type $aIpArray + * @return boolean + */ public function enableDebugByIp($aIpArray){ $this->enableDebug(false); if (!$_SERVER || !is_array($_SERVER) || !array_key_exists("REMOTE_ADDR", $_SERVER)){ @@ -71,18 +76,49 @@ class logger { } $sOut=''; $sStarttime=$this->aMessages[0]["time"]; + + $iCounter=0; + $sMaxRowId=false; + $iMaxtime=-1; + $sWarnings=false; + $iLasttime=$sStarttime; + foreach ($this->aMessages as $aLogentry){ - $sOut.='<tr class="'.$aLogentry["level"].'">'. - '<!-- <td>'.$aLogentry["time"].'</td> -->'. - '<td>'.sprintf("%01.4f", $aLogentry["time"]-$sStarttime).'</td>'. - '<td>'.sprintf("%01.4f", $aLogentry["time"]-$iLasttime).'</td>'. + $iCounter++; + $sTrId='debugTableRow'.$iCounter; + $iDelta=$aLogentry["time"]-$iLasttime; + if ($iDelta > $iMaxtime){ + $iMaxtime=$iDelta; + $sMaxRowId=$sTrId; + } + + + $sStyle=($iDelta > 1)?'color: #f82;':''; + if (($iDelta > 1)){ + $sWarnings.='<a href="#'.$sTrId.'" title="'.sprintf("%01.4f", $iDelta).' s">'.$iCounter.'</a> '; + } + $sOut.='<tr class="'.$aLogentry["level"].'" id="'.$sTrId.'" style="'.$sStyle.'">'. + '<td>'.$iCounter.'</td>'. + '<td>'.sprintf("%01.3f", $aLogentry["time"]-$sStarttime).'</td>'. + '<td>'.sprintf("%01.3f", $iDelta).'</td>'. '<td>'.$aLogentry["level"].'</td>'. '<td>'.$aLogentry["message"].'</td>'. '</tr>'; $iLasttime=$aLogentry["time"]; + } + $iTotal=$iLasttime-$sStarttime; + if ($sWarnings){ + $sWarnings='<br>warnings: '.$sWarnings; + } + if ($sOut) $sOut=' + <div style="position: fixed; right: 1em; top: 6em; background: rgba(255,80,80, 0.1); padding: 0.5em;"> + <span style="font-size: 130%;">total: '.sprintf("%01.3f", $iTotal).' s</span><br> + <span>longest action: <a href="#'.$sMaxRowId.'">'.sprintf("%01.3f", $iMaxtime).' s</a></span> + <span>'.$sWarnings.'</span> + </div> <br> <br> <br> @@ -92,13 +128,14 @@ class logger { <table class="datatable table table-striped debugtable"> <thead> <tr> - <!-- <th>time</th> --> + <th>#</th> <th>delta to start time</th> <th>delta to previuos</th> <th>level</th> <th>message</th> </tr></thead><tbody> - '.$sOut.'</tbody></table>'; + '.$sOut.'</tbody></table>' + . '<script>$(\'#'.$sMaxRowId.'\').css(\'color\', \'#f00\');</script>'; return $sOut; } }