diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index 25427152..c50ba3ff 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -68,6 +68,14 @@ function test2(): array return DebugSupport::getCallerMethodList(1); } +// date stueff +print "printTime(-1): " . DebugSupport::printTime() . "
"; +print "printTime(2): " . DebugSupport::printTime(2) . "
"; +print "printTime(3): " . DebugSupport::printTime(3) . "
"; +print "printTime(5): " . DebugSupport::printTime(5) . "
"; +print "printIsoTime(): " . DebugSupport::printIsoTime() . "
"; +print "printIsoTime(false): " . DebugSupport::printIsoTime(false) . "
"; + print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "
"; print "S::GETCALLERMETHOD: " . test() . "
"; print "S::GETCALLERMETHODLIST:
" . print_r(test2(), true) . "

"; @@ -146,7 +154,7 @@ print "LOG LEVEL: " . DebugSupport::printAr(\CoreLibs\Convert\SetVarType::setAr $new_log->getLogLevel('debug', 'on') )) . "
"; -echo "CLASS DEBUG CALL
"; +echo "CLASS DEBUG CALL LEGACY
"; // @codingStandardsIgnoreLine class TestL diff --git a/www/lib/CoreLibs/Debug/Support.php b/www/lib/CoreLibs/Debug/Support.php index affec0f7..beabd0a8 100644 --- a/www/lib/CoreLibs/Debug/Support.php +++ b/www/lib/CoreLibs/Debug/Support.php @@ -33,6 +33,36 @@ class Support return $string; } + /** + * print ISO type datetime with microseconds and timezone + * Y-m-dTH:i:s.uP + * if no micro time the ".u" part is omitted + * + * @param bool $set_micro_time + * @return string + */ + public static function printIsoTime(bool $set_micro_time = true): string + { + $datetime = new \DateTime(); + + // Format the DateTime object to ISO 8601 with microseconds + // 'Y-m-d\TH:i:s.uP' is the format string: + // Y: Full year (e.g., 2025) + // m: Month (01-12) + // d: Day of the month (01-31) + // T: Literal 'T' to separate date and time (escaped with a backslash) + // H: Hour (00-23) + // i: Minute (00-59) + // s: Second (00-59) + // u: Microseconds (e.g., 654321) + // P: Difference to Greenwich time (GMT) with colon (e.g., +09:00) + if ($set_micro_time) { + return $datetime->format('Y-m-d\TH:i:s.uP'); + } else { + return $datetime->format('Y-m-d\TH:i:sP'); + } + } + /** * prints a html formatted (pre) data * diff --git a/www/lib/CoreLibs/Logging/Logging.php b/www/lib/CoreLibs/Logging/Logging.php index 334ed6ca..82719b02 100644 --- a/www/lib/CoreLibs/Logging/Logging.php +++ b/www/lib/CoreLibs/Logging/Logging.php @@ -96,6 +96,11 @@ class Logging 'type' => 'bool', 'mandatory' => false, 'default' => false, 'deprecated' => true, 'use' => 'log_per_date' ], + // if turned off uses old time format without time zone + 'log_time_format_iso' => [ + 'type' => 'bool', 'mandatory' => false, + 'default' => true + ] ]; // options @@ -646,7 +651,11 @@ class Logging } // print "CLASS: " . $class . "
"; // get timestamp - $timestamp = Support::printTime(); + if (!empty($this->options['log_time_format_iso'])) { + $timestamp = Support::printIsoTime(); + } else { + $timestamp = Support::printTime(); + } // if group id is empty replace it with current level $group_str = $level->getName();