diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index f07f5df8..7d8d0149 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -86,6 +86,7 @@ class TestR extends TestL print "** GETCALLERCLASS(INSIDE EXTND CLASS): ".\CoreLibs\Debug\Support::getCallerClass()."
"; $this->log->debug('TESTR', 'Logging in class testR (extends testL)'); $this->test('TESTR INSIDE'); + $this->log->debug('TESTR', 'Array: '.$this->log->prAr(['a', 'b']).', Other: '.$this->log->prAr(['a', 'b'])); return true; } } @@ -109,7 +110,7 @@ print "S::FDEBUG: ".FileWriter::fdebug('CLASS TEST DEBUG FILE: '.date('Y-m-d H:i // future DEPRECATED // $basic->debug('BASIC CLASS', 'Debug test'); $basic->log->debug('BASIC CLASS', 'Debug test'); -print "BASIC:
".$basic->log->printErrorMsg(); +print "BASIC PRINTERRORMSG:
".$basic->log->printErrorMsg(); print ""; diff --git a/www/admin/class_test.php b/www/admin/class_test.php index 8d724d4c..cac7bd43 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -3,10 +3,10 @@ * @phan-file-suppress PhanTypeSuspiciousStringExpression */ -$DEBUG_ALL_OVERRIDE = 0; // set to 1 to debug on live/remote server locations -$DEBUG_ALL = 1; -$PRINT_ALL = 1; -$DB_DEBUG = 1; +$DEBUG_ALL_OVERRIDE = false; // set to 1 to debug on live/remote server locations +$DEBUG_ALL = true; +$PRINT_ALL = true; +$DB_DEBUG = true; if ($DEBUG_ALL) { error_reporting(E_ALL | E_STRICT | E_ERROR | E_WARNING | E_PARSE | E_COMPILE_ERROR); @@ -91,6 +91,7 @@ foreach (['debug', 'echo', 'print'] as $type) { $basic->log->debug('SOME MARK', 'Some error output'); +// INTERNAL SET print "EDIT ACCESS ID: ".$basic->edit_access_id."
"; if (is_object($login)) { // print "ACL:
".$basic->print_ar($login->acl)."
"; diff --git a/www/lib/CoreLibs/Debug/Logging.php b/www/lib/CoreLibs/Debug/Logging.php index 233db905..7d7e1a4a 100644 --- a/www/lib/CoreLibs/Debug/Logging.php +++ b/www/lib/CoreLibs/Debug/Logging.php @@ -413,6 +413,20 @@ class Logging return $this->{'log_per_'.$type}; } + /** + * A replacement for the \CoreLibs\Debug\Support::printAr + * But this does not wrap it in

+	 * It uses some special code sets so we can convert that to pre flags
+	 * for echo output {##HTMLPRE##} ... {##/HTMLPRE##}
+	 * Do not use this without using it in a string in debug function
+	 * @param  array $a Array to format
+	 * @return string   print_r formated
+	 */
+	public function prAr(array $a): string
+	{
+		return '{##HTMLPRE##}'.print_r($a, true).'{##/HTMLPRE##}';
+	}
+
 	/**
 	 * write debug data to error_msg array
 	 * @param  string $level  id for error message, groups messages together
@@ -441,12 +455,17 @@ class Logging
 			.'['.$this->running_uid.'] '
 			.'{'.$class.'} '
 			.'<'.$level.'> - '
-			// if stripping all html, etc is requested, only for write error msg
-			.($strip ?
-				// find any 
and replace them with \n - // strip rest of html elements (base only) - preg_replace("/(<\/?)(\w+)([^>]*>)/", '[\\2]', str_replace('
', "\n", $string)) : - $string + // strip the htmlpre special tags if exist + .preg_replace( + "/{##HTMLPRE##}((.|\n)*?){##\/HTMLPRE##}/m", + '\\1', + // if stripping all html, etc is requested, only for write error msg + ($strip ? + // find any
and replace them with \n + // strip rest of html elements (base only) + preg_replace("/(<\/?)(\w+)([^>]*>)/", '', str_replace('
', "\n", $string)) : + $string + ) ) ."\n" ); @@ -463,7 +482,9 @@ class Logging .'['.$this->host_name.'] ' .'['.$this->page_name.'] ' .'['.$this->running_uid.'] ' - .'{'.$class.'} - '.\CoreLibs\Convert\Html::htmlent($string) + .'{'.$class.'} - ' + // we replace special HTMLPRE with
 entries
+				.preg_replace("/{##HTMLPRE##}((.|\n)*?){##\/HTMLPRE##}/m", "
\\1
", \CoreLibs\Convert\Html::htmlent($string)) .""; } return true; diff --git a/www/lib/CoreLibs/Debug/Support.php b/www/lib/CoreLibs/Debug/Support.php index f37d7a34..1014d9e1 100644 --- a/www/lib/CoreLibs/Debug/Support.php +++ b/www/lib/CoreLibs/Debug/Support.php @@ -60,13 +60,17 @@ class Support * Get the current class where this function is called * Is mostly used in debug log statements to get the class where the debug was called * gets top level class - * + * loops over the debug backtrace until if finds the first class (from the end) * @return string Class name with namespace */ public static function getCallerClass(): string { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) ?? [['class' => get_called_class()]]; - return end($backtrace)['class']; + $class = null; + while ($class === null) { + $class = array_pop($backtrace)['class'] ?? null; + } + return $class ?? ''; } }