@@ -79,8 +79,8 @@ |
||
| 79 | 79 | <html> |
| 80 | 80 | <body> |
| 81 | 81 | <h1>Logger - Example</h1> |
| 82 | - <p><?php echo $strMessage;?></p> |
|
| 83 | - <p><?php echo $strLink;?></p> |
|
| 82 | + <p><?php echo $strMessage; ?></p> |
|
| 83 | + <p><?php echo $strLink; ?></p> |
|
| 84 | 84 | <form action="XLogTest.php" method="get"> |
| 85 | 85 | <label for="logger">Output to:</label> |
| 86 | 86 | <select name="logger" id ="logger"> |
@@ -1,5 +1,5 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -declare(strict_types = 1); |
|
| 2 | +declare(strict_types=1); |
|
| 3 | 3 | |
| 4 | 4 | namespace SKien\XLogger; |
| 5 | 5 | |
@@ -120,7 +120,7 @@ discard block |
||
| 120 | 120 | */ |
| 121 | 121 | protected function openLogfile() : void |
| 122 | 122 | { |
| 123 | - if (!$this->xmlDoc || !$this->xmlRoot) { |
|
| 123 | + if (!$this->xmlDoc || !$this->xmlRoot) { |
|
| 124 | 124 | $strFullPath = $this->getFullpath(); |
| 125 | 125 | if (!file_exists($strFullPath)) { |
| 126 | 126 | $this->createLogfile(); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | * @param \DOMElement $oParent |
| 176 | 176 | * @return \DOMElement |
| 177 | 177 | */ |
| 178 | - public function addChildToDoc(string $strName, string $strValue='', \DOMElement $oParent=null) : ?\DOMElement |
|
| 178 | + public function addChildToDoc(string $strName, string $strValue = '', \DOMElement $oParent = null) : ?\DOMElement |
|
| 179 | 179 | { |
| 180 | 180 | $oChild = null; |
| 181 | 181 | if ($this->xmlDoc) { |
@@ -70,7 +70,7 @@ |
||
| 70 | 70 | ChromePhp::log($strMessage); |
| 71 | 71 | break; |
| 72 | 72 | } |
| 73 | - if (count($context) >0) { |
|
| 73 | + if (count($context) > 0) { |
|
| 74 | 74 | ChromePhp::group(); |
| 75 | 75 | foreach ($context as $key => $value) { |
| 76 | 76 | // only add, if not included as placeholder in the mesage |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | // timestamp |
| 77 | - $strLine = date('Y-m-d H:i:s'); |
|
| 77 | + $strLine = date('Y-m-d H:i:s'); |
|
| 78 | 78 | // IP adress |
| 79 | - if (($this->iOptions & self::LOG_IP) != 0 ) { |
|
| 79 | + if (($this->iOptions & self::LOG_IP) != 0) { |
|
| 80 | 80 | $strIP = $_SERVER['REMOTE_ADDR']; |
| 81 | 81 | if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
| 82 | 82 | $strIP = $_SERVER['HTTP_X_FORWARDED_FOR']; |
@@ -84,18 +84,18 @@ discard block |
||
| 84 | 84 | $strLine .= $this->strSep . $strIP; |
| 85 | 85 | } |
| 86 | 86 | // user |
| 87 | - if (($this->iOptions & self::LOG_USER) != 0 ) { |
|
| 87 | + if (($this->iOptions & self::LOG_USER) != 0) { |
|
| 88 | 88 | $strLine .= $this->strSep . $this->prepareText($this->strUser); |
| 89 | 89 | } |
| 90 | 90 | // backtrace - caller |
| 91 | - if (($this->iOptions & self::LOG_BT) != 0 ) { |
|
| 91 | + if (($this->iOptions & self::LOG_BT) != 0) { |
|
| 92 | 92 | $strLine .= $this->strSep . $this->getCaller(); |
| 93 | 93 | } |
| 94 | 94 | // the message |
| 95 | 95 | $strMessage = $this->replaceContext($message, $context); |
| 96 | 96 | $strLine .= $this->strSep . $this->prepareText(strtoupper($level) . ': ' . $strMessage); |
| 97 | 97 | // user agent |
| 98 | - if (($this->iOptions & self::LOG_BT) != 0 ) { |
|
| 98 | + if (($this->iOptions & self::LOG_BT) != 0) { |
|
| 99 | 99 | $strLine .= $this->strSep . $this->prepareText($_SERVER["HTTP_USER_AGENT"]); |
| 100 | 100 | } |
| 101 | 101 | |
@@ -120,12 +120,12 @@ discard block |
||
| 120 | 120 | case 'csv': |
| 121 | 121 | case 'txt': |
| 122 | 122 | $this->strSep = ";"; |
| 123 | - $this->strReplace =","; |
|
| 123 | + $this->strReplace = ","; |
|
| 124 | 124 | break; |
| 125 | 125 | case 'log': |
| 126 | 126 | default: |
| 127 | 127 | $this->strSep = "\t"; |
| 128 | - $this->strReplace =" "; |
|
| 128 | + $this->strReplace = " "; |
|
| 129 | 129 | break; |
| 130 | 130 | } |
| 131 | 131 | $this->logfile = fopen($strFullPath, 'a'); |
@@ -80,7 +80,7 @@ |
||
| 80 | 80 | $this->fb->log($strMessage); |
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | - if (count($context) >0) { |
|
| 83 | + if (count($context) > 0) { |
|
| 84 | 84 | // $this->fb->group('context'); |
| 85 | 85 | foreach ($context as $key => $value) { |
| 86 | 86 | // only add, if not included as placeholder in the mesage |
@@ -204,7 +204,7 @@ |
||
| 204 | 204 | if ($aCaller) { |
| 205 | 205 | // the base path on server isn't from interest.. |
| 206 | 206 | $strFile = str_replace($_SERVER['DOCUMENT_ROOT'], '', $aCaller['file']); |
| 207 | - $strCaller = $strFile . ' ('.$aCaller['line'].')'; |
|
| 207 | + $strCaller = $strFile . ' (' . $aCaller['line'] . ')'; |
|
| 208 | 208 | } |
| 209 | 209 | return $strCaller; |
| 210 | 210 | } |
@@ -2,7 +2,7 @@ |
||
| 2 | 2 | spl_autoload_register(function($strClassName) |
| 3 | 3 | { |
| 4 | 4 | $strInclude = ''; |
| 5 | - if( substr( $strClassName, 0, 5 ) == 'Table' ) { |
|
| 5 | + if (substr($strClassName, 0, 5) == 'Table') { |
|
| 6 | 6 | $strClassName = str_replace('Table', 't', $strClassName); |
| 7 | 7 | $strInclude = 'common/dbdesign/' . $strClassName . '.php'; |
| 8 | 8 | } |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | * |
| 75 | 75 | * @var string |
| 76 | 76 | */ |
| 77 | - const VERSION = '0.3'; // @pinf replace '0.3' with '%%VERSION%%' |
|
| 77 | + const VERSION = '0.3'; // @pinf replace '0.3' with '%%VERSION%%' |
|
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | 80 | * Firebug LOG level |
@@ -256,7 +256,7 @@ discard block |
||
| 256 | 256 | */ |
| 257 | 257 | protected $logToInsightConsole = null; |
| 258 | 258 | |
| 259 | - function __construct () |
|
| 259 | + function __construct() |
|
| 260 | 260 | { |
| 261 | 261 | $this->ignoredInTraces['paths'][__DIR__] = true; |
| 262 | 262 | $this->ignoredInTraces['paths'][__FILE__] = true; |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | * |
| 366 | 366 | * @param string $class The class name to ignore |
| 367 | 367 | */ |
| 368 | - public function ignoreClassInTraces ($class) |
|
| 368 | + public function ignoreClassInTraces($class) |
|
| 369 | 369 | { |
| 370 | 370 | $this->ignoredInTraces['classes'][$class] = true; |
| 371 | 371 | } |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | * |
| 376 | 376 | * @param string $path The path prefix to ignore |
| 377 | 377 | */ |
| 378 | - public function ignorePathInTraces ($path) |
|
| 378 | + public function ignorePathInTraces($path) |
|
| 379 | 379 | { |
| 380 | 380 | $this->ignoredInTraces['paths'][$path] = true; |
| 381 | 381 | } |
@@ -810,7 +810,7 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @param string $trace A debug_backtrace() trace |
| 812 | 812 | */ |
| 813 | - protected function filterDebugBacktrace ($trace, $offset = 0) { |
|
| 813 | + protected function filterDebugBacktrace($trace, $offset = 0) { |
|
| 814 | 814 | $discardedTrace = array(); |
| 815 | 815 | $filteredTrace = array(); |
| 816 | 816 | for ($i = 0; $i < sizeof($trace); $i++) { |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | isset($this->ignoredInTraces['classes'][$trace[$i]['class']]) || |
| 822 | 822 | array_reduce( |
| 823 | 823 | array_keys($this->ignoredInTraces['classes']), |
| 824 | - function ($carry, $class) use ($trace, $i) |
|
| 824 | + function($carry, $class) use ($trace, $i) |
|
| 825 | 825 | { |
| 826 | 826 | if (strpos($trace[$i]['class'], $class) === 0) { |
| 827 | 827 | $carry += 1; |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | isset($this->ignoredInTraces['paths'][$trace[$i]['file']]) || |
| 843 | 843 | array_reduce( |
| 844 | 844 | array_keys($this->ignoredInTraces['paths']), |
| 845 | - function ($carry, $path) use ($trace, $i) |
|
| 845 | + function($carry, $path) use ($trace, $i) |
|
| 846 | 846 | { |
| 847 | 847 | if (strpos($trace[$i]['file'], $path) === 0) { |
| 848 | 848 | $carry += 1; |
@@ -859,7 +859,7 @@ discard block |
||
| 859 | 859 | array_push($filteredTrace, $trace[$i]); |
| 860 | 860 | } |
| 861 | 861 | if ($offset < 0) { |
| 862 | - for ($i = sizeof($discardedTrace) -1; $i >= ($offset * -1); $i--) { |
|
| 862 | + for ($i = sizeof($discardedTrace) - 1; $i >= ($offset * -1); $i--) { |
|
| 863 | 863 | array_unshift($filteredTrace, $discardedTrace[$i]); |
| 864 | 864 | } |
| 865 | 865 | } |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | |
| 937 | 937 | // Get folder name where firephp is located. |
| 938 | 938 | $parentFolder = basename(dirname(__FILE__)); |
| 939 | - $parentFolderLength = strlen( $parentFolder ); |
|
| 939 | + $parentFolderLength = strlen($parentFolder); |
|
| 940 | 940 | $fbLength = 7 + $parentFolderLength; |
| 941 | 941 | $fireClassLength = 18 + $parentFolderLength; |
| 942 | 942 | |
@@ -951,16 +951,16 @@ discard block |
||
| 951 | 951 | } |
| 952 | 952 | if (isset($trace[$i]['file'])) { |
| 953 | 953 | $path = $this->_standardizePath($trace[$i]['file']); |
| 954 | - if (substr($path, -1*$fbLength, $fbLength) == $parentFolder.'/fb.php' || substr($path, -1*$fireClassLength, $fireClassLength) == $parentFolder.'/FirePHP.class.php') { |
|
| 954 | + if (substr($path, -1 * $fbLength, $fbLength) == $parentFolder . '/fb.php' || substr($path, -1 * $fireClassLength, $fireClassLength) == $parentFolder . '/FirePHP.class.php') { |
|
| 955 | 955 | continue; |
| 956 | 956 | } |
| 957 | 957 | } |
| 958 | 958 | if (isset($trace[$i]['function']) && $trace[$i]['function'] == 'fb' && |
| 959 | - isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -1*$fbLength, $fbLength) == $parentFolder.'/fb.php') { |
|
| 959 | + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -1 * $fbLength, $fbLength) == $parentFolder . '/fb.php') { |
|
| 960 | 960 | continue; |
| 961 | 961 | } |
| 962 | 962 | if (isset($trace[$i]['class']) && $trace[$i]['class'] == 'FB' && |
| 963 | - isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -1*$fbLength, $fbLength) == $parentFolder.'/fb.php') { |
|
| 963 | + isset($trace[$i - 1]['file']) && substr($this->_standardizePath($trace[$i - 1]['file']), -1 * $fbLength, $fbLength) == $parentFolder . '/fb.php') { |
|
| 964 | 964 | continue; |
| 965 | 965 | } |
| 966 | 966 | break; |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | |
| 1208 | 1208 | if ($this->options['includeLineNumbers']) { |
| 1209 | 1209 | if (!isset($meta['file']) || !isset($meta['line'])) { |
| 1210 | - $trace = $this->filterDebugBacktrace(debug_backtrace()); // ??? why?... don't work correctly anyway.... , -1); |
|
| 1210 | + $trace = $this->filterDebugBacktrace(debug_backtrace()); // ??? why?... don't work correctly anyway.... , -1); |
|
| 1211 | 1211 | $encounteredCount = 0; |
| 1212 | 1212 | for ($i = 0; $trace && $i < sizeof($trace); $i++) { |
| 1213 | 1213 | if ( |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | //#2801 is_resource reports false for closed resources https://bugs.php.net/bug.php?id=28016 |
| 1512 | 1512 | if (is_resource($object) || gettype($object) === "unknown type") { |
| 1513 | 1513 | |
| 1514 | - return '** ' . (string) $object . ' **'; |
|
| 1514 | + return '** ' . (string)$object . ' **'; |
|
| 1515 | 1515 | |
| 1516 | 1516 | } else if (is_object($object)) { |
| 1517 | 1517 | |
@@ -1679,11 +1679,11 @@ discard block |
||
| 1679 | 1679 | return '** Max Depth (' . $maxDepth . ') **'; |
| 1680 | 1680 | } |
| 1681 | 1681 | |
| 1682 | - } elseif ( is_bool($object) ) { |
|
| 1682 | + } elseif (is_bool($object)) { |
|
| 1683 | 1683 | return $object; |
| 1684 | - } elseif ( is_null($object) ) { |
|
| 1684 | + } elseif (is_null($object)) { |
|
| 1685 | 1685 | return $object; |
| 1686 | - } elseif ( is_numeric($object) ) { |
|
| 1686 | + } elseif (is_numeric($object)) { |
|
| 1687 | 1687 | return $object; |
| 1688 | 1688 | } else { |
| 1689 | 1689 | if ($this->is_utf8($object)) { |
@@ -1724,7 +1724,7 @@ discard block |
||
| 1724 | 1724 | elseif ($c >= 192) $bits = 2; |
| 1725 | 1725 | else return false; |
| 1726 | 1726 | if (($i + $bits) > $len) return false; |
| 1727 | - while($bits > 1) { |
|
| 1727 | + while ($bits > 1) { |
|
| 1728 | 1728 | $i++; |
| 1729 | 1729 | $b = ord($str[$i]); |
| 1730 | 1730 | if ($b < 128 || $b > 191) return false; |
@@ -1869,11 +1869,11 @@ discard block |
||
| 1869 | 1869 | return 'null'; |
| 1870 | 1870 | |
| 1871 | 1871 | case 'integer': |
| 1872 | - return (int) $var; |
|
| 1872 | + return (int)$var; |
|
| 1873 | 1873 | |
| 1874 | 1874 | case 'double': |
| 1875 | 1875 | case 'float': |
| 1876 | - return (float) $var; |
|
| 1876 | + return (float)$var; |
|
| 1877 | 1877 | |
| 1878 | 1878 | case 'string': |
| 1879 | 1879 | // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param array $options OPTIONAL Instructions on how to log the group |
| 157 | 157 | * @return true |
| 158 | 158 | */ |
| 159 | - public static function group($name, $options=null) |
|
| 159 | + public static function group($name, $options = null) |
|
| 160 | 160 | { |
| 161 | 161 | return FirePHP::getInstance(true)->group($name, $options); |
| 162 | 162 | } |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @return true |
| 182 | 182 | * @throws \Exception |
| 183 | 183 | */ |
| 184 | - public static function log($object, $label=null) |
|
| 184 | + public static function log($object, $label = null) |
|
| 185 | 185 | { |
| 186 | 186 | return self::send($object, $label, FirePHP::LOG); |
| 187 | 187 | } |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | * @return true |
| 196 | 196 | * @throws \Exception |
| 197 | 197 | */ |
| 198 | - public static function info($object, $label=null) |
|
| 198 | + public static function info($object, $label = null) |
|
| 199 | 199 | { |
| 200 | 200 | return self::send($object, $label, FirePHP::INFO); |
| 201 | 201 | } |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | * @return true |
| 210 | 210 | * @throws \Exception |
| 211 | 211 | */ |
| 212 | - public static function warn($object, $label=null) |
|
| 212 | + public static function warn($object, $label = null) |
|
| 213 | 213 | { |
| 214 | 214 | return self::send($object, $label, FirePHP::WARN); |
| 215 | 215 | } |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | * @return true |
| 224 | 224 | * @throws \Exception |
| 225 | 225 | */ |
| 226 | - public static function error($object, $label=null) |
|
| 226 | + public static function error($object, $label = null) |
|
| 227 | 227 | { |
| 228 | 228 | return self::send($object, $label, FirePHP::ERROR); |
| 229 | 229 | } |