Add ISO Type datetime format to support, and make this default loggint time format
This commit is contained in:
@@ -68,6 +68,14 @@ function test2(): array
|
|||||||
return DebugSupport::getCallerMethodList(1);
|
return DebugSupport::getCallerMethodList(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// date stueff
|
||||||
|
print "printTime(-1): " . DebugSupport::printTime() . "<br>";
|
||||||
|
print "printTime(2): " . DebugSupport::printTime(2) . "<br>";
|
||||||
|
print "printTime(3): " . DebugSupport::printTime(3) . "<br>";
|
||||||
|
print "printTime(5): " . DebugSupport::printTime(5) . "<br>";
|
||||||
|
print "printIsoTime(): " . DebugSupport::printIsoTime() . "<br>";
|
||||||
|
print "printIsoTime(false): " . DebugSupport::printIsoTime(false) . "<br>";
|
||||||
|
|
||||||
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "<br>";
|
print "S::GETCALLERMETHOD: " . DebugSupport::getCallerMethod(0) . "<br>";
|
||||||
print "S::GETCALLERMETHOD: " . test() . "<br>";
|
print "S::GETCALLERMETHOD: " . test() . "<br>";
|
||||||
print "S::GETCALLERMETHODLIST: <pre>" . print_r(test2(), true) . "</pre><br>";
|
print "S::GETCALLERMETHODLIST: <pre>" . print_r(test2(), true) . "</pre><br>";
|
||||||
@@ -146,7 +154,7 @@ print "LOG LEVEL: " . DebugSupport::printAr(\CoreLibs\Convert\SetVarType::setAr
|
|||||||
$new_log->getLogLevel('debug', 'on')
|
$new_log->getLogLevel('debug', 'on')
|
||||||
)) . "<br>";
|
)) . "<br>";
|
||||||
|
|
||||||
echo "<b>CLASS DEBUG CALL</b><br>";
|
echo "<b>CLASS DEBUG CALL LEGACY</b><br>";
|
||||||
|
|
||||||
// @codingStandardsIgnoreLine
|
// @codingStandardsIgnoreLine
|
||||||
class TestL
|
class TestL
|
||||||
|
|||||||
@@ -33,6 +33,36 @@ class Support
|
|||||||
return $string;
|
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
|
* prints a html formatted (pre) data
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -96,6 +96,11 @@ class Logging
|
|||||||
'type' => 'bool', 'mandatory' => false,
|
'type' => 'bool', 'mandatory' => false,
|
||||||
'default' => false, 'deprecated' => true, 'use' => 'log_per_date'
|
'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
|
// options
|
||||||
@@ -646,7 +651,11 @@ class Logging
|
|||||||
}
|
}
|
||||||
// print "CLASS: " . $class . "<br>";
|
// print "CLASS: " . $class . "<br>";
|
||||||
// get timestamp
|
// 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
|
// if group id is empty replace it with current level
|
||||||
$group_str = $level->getName();
|
$group_str = $level->getName();
|
||||||
|
|||||||
Reference in New Issue
Block a user