X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fmain%2Fclasses%2Fclass_BaseFrameworkSystem.php;h=f5e051041c47dd9c032909993b6509be01b4b09d;hp=4c891596964ad8dbb1fcaa0e577a4b71e2e3e708;hb=d039c03a31f4223ba124c69aed9a58f2dccefdb6;hpb=eb295c2b1147cacdf066106987db63b2f5f7886d diff --git a/inc/main/classes/class_BaseFrameworkSystem.php b/inc/main/classes/class_BaseFrameworkSystem.php index 4c891596..f5e05104 100644 --- a/inc/main/classes/class_BaseFrameworkSystem.php +++ b/inc/main/classes/class_BaseFrameworkSystem.php @@ -6,11 +6,13 @@ namespace CoreFramework\Object; use CoreFramework\Configuration\FrameworkConfiguration; use CoreFramework\Factory\ObjectFactory; use CoreFramework\Generic\FrameworkInterface; +use CoreFramework\Generic\NullPointerException; use CoreFramework\Loader\ClassLoader; use CoreFramework\Manager\ManageableApplication; use CoreFramework\Middleware\Debug\DebugMiddleware; use CoreFramework\Registry\Register; use CoreFramework\Registry\Generic\Registry; +use CoreFramework\Stream\Output\OutputStreamer; use CoreFramework\Template\CompileableTemplate; // Import SPL stuff @@ -475,7 +477,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $this->setRealClass('DestructedObject'); } elseif ((defined('DEBUG_DESTRUCTOR')) && (is_object($this->getDebugInstance()))) { // Already destructed object - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:] The object %s is already destroyed.', + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[%s:] The object %s is already destroyed.', __CLASS__, $this->__toString() )); @@ -505,6 +507,9 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public static final function __callStatic ($methodName, $args) { + // Trace message + //* PRINT-DEBUG: */ printf('[%s:%d]: methodName=%s,args[]=%s - CALLED!' . PHP_EOL, __METHOD__, __LINE__, $methodName, gettype($args)); + // Init argument string $argsString = ''; @@ -565,7 +570,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Output stub message // @TODO __CLASS__ does always return BaseFrameworkSystem but not the extending (=child) class - self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s', + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput(sprintf('[unknown::%s:] Stub! Args: %s', $methodName, $argsString )); @@ -1199,7 +1204,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function setSocketResource ($socketResource) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource=' . $socketResource . ',previous[' . gettype($this->socketResource) . ']=' . $this->socketResource); $this->socketResource = $socketResource; } @@ -1209,7 +1214,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $socketResource A valid socket resource */ public final function getSocketResource () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': socketResource[' . gettype($this->socketResource) . ']=' . $this->socketResource); return $this->socketResource; } @@ -1220,7 +1225,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return void */ public final function setRegularExpression ($regularExpression) { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression=' . $regularExpression . ',previous[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); $this->regularExpression = $regularExpression; } @@ -1230,7 +1235,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * @return $regularExpression A valid regular expression */ public final function getRegularExpression () { - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . '::' . __FUNCTION__ . ': regularExpression[' . gettype($this->regularExpression) . ']=' . $this->regularExpression); return $this->regularExpression; } @@ -1859,7 +1864,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - self::createDebugInstance(__CLASS__)->debugOutput($stubMessage); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($stubMessage); } else { // Trigger an error trigger_error($stubMessage); @@ -1895,10 +1900,11 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { * Creates an instance of a debugger instance * * @param $className Name of the class (currently unsupported) + * @param $lineNumber Line number where the call was made * @return $debugInstance An instance of a debugger class * @deprecated Not fully, as the new Logger facilities are not finished yet. */ - public final static function createDebugInstance ($className) { + public final static function createDebugInstance ($className, $lineNumber = NULL) { // Is the instance set? if (!Registry::getRegistry()->instanceExists('debug')) { // Init debug instance @@ -1910,7 +1916,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $debugInstance = DebugMiddleware::createDebugMiddleware(FrameworkConfiguration::getSelfInstance()->getConfigEntry('debug_' . self::getResponseTypeFromSystem() . '_class'), $className); } catch (NullPointerException $e) { // Didn't work, no instance there - exit('Cannot create debugInstance! Exception=' . $e->__toString() . ', message=' . $e->getMessage()); + exit(sprintf('Cannot create debugInstance! Exception=%s,message=%s,className=%s,lineNumber=%d' . PHP_EOL, $e->__toString(), $e->getMessage(), $className, $lineNumber)); } // Empty string should be ignored and used for testing the middleware @@ -2183,7 +2189,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current array $fieldArray = $resultInstance->current(); - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($fieldName.':
'.print_r($fieldArray, TRUE).'
'); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($fieldName.':
'.print_r($fieldArray, TRUE).'
'); // Convert dashes to underscore $fieldName2 = self::convertDashesToUnderscores($fieldName); @@ -2194,10 +2200,10 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { $fieldValue = $fieldArray[$fieldName2]; } elseif (defined('DEVELOPER')) { // Missing field entry, may require debugging - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, TRUE) . '
,fieldName=' . $fieldName . ' not found!'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldArray
=' . print_r($fieldArray, TRUE) . '
,fieldName=' . $fieldName . ' not found!'); } else { // Missing field entry, may require debugging - self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!'); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']:fieldName=' . $fieldName . ' not found!'); } // Return it @@ -2223,7 +2229,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Get current array $fieldArray = $resultInstance->current(); - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, TRUE).'
'); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('[' . $this->__toString() . ':' . __LINE__ . '] fieldName=' . $fieldName . ',fieldArray=
'.print_r($fieldArray, TRUE).'
'); // Convert dashes to underscore $fieldName = self::convertDashesToUnderscores($fieldName); @@ -2270,7 +2276,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { // Debug instance is there? if (!is_null($this->getDebugInstance())) { // Output stub message - self::createDebugInstance(__CLASS__)->debugOutput($message); + self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($message); } else { // Trigger an error trigger_error($message . "
\n"); @@ -2458,7 +2464,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function hex2asc ($hex) { // Check for length, it must be devideable by 2 - //* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('hex='.$hex); + //* DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('hex='.$hex); assert((strlen($hex) % 2) == 0); // Walk the string @@ -2526,7 +2532,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { ); // And return it - //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); + //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput($this->__toString() . ': cacheKey=' . $cacheKey); return $cacheKey; } @@ -3309,7 +3315,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { */ protected function packString ($str) { // Debug message - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('str=' . $str . ' - CALLED!'); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('str=' . $str . ' - CALLED!'); // First compress the string (gzcompress is okay) $str = gzcompress($str); @@ -3344,7 +3350,7 @@ class BaseFrameworkSystem extends stdClass implements FrameworkInterface { } // END - for // Return it - //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__)->debugOutput('packed=' . $packed . ' - EXIT!'); + //* NOISY-DEBUG */ self::createDebugInstance(__CLASS__, __LINE__)->debugOutput('packed=' . $packed . ' - EXIT!'); return $packed; }