- Added time output

This commit is contained in:
Dave Mc Nicoll 2024-04-24 11:25:08 -04:00
parent 6c074a249e
commit b99ff24d26
1 changed files with 5 additions and 4 deletions

View File

@ -15,10 +15,10 @@ class Dump {
protected $content = null; protected $content = null;
public function __construct(...$content) { public function __construct(...$content) {
$this->trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2] ?? [ $this->trace = (debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2] ?? [
"line" => -1, "line" => -1,
"file" => "unknown", "file" => "unknown",
]; ]) + [ 'time' => round(1000 * (microtime(true) - $_SERVER["REQUEST_TIME_FLOAT"]), 4) ];
$this->content = $content; $this->content = $content;
} }
@ -28,6 +28,7 @@ class Dump {
'content' => $this->content, 'content' => $this->content,
'file' => $this->trace['file'] ?? '?', 'file' => $this->trace['file'] ?? '?',
'line' => $this->trace['line'] ?? '?', 'line' => $this->trace['line'] ?? '?',
'time' => $this->trace['time'],
]; ];
} }
@ -39,7 +40,7 @@ class Dump {
return <<<HTML return <<<HTML
<pre style='-webkit-overflow-scrolling: touch;background-color: #f5f5f5;color: #4a4a4a;font-size: 12px;line-height:18px;overflow-x: auto;padding: 0.5rem 1.5rem;word-wrap: normal;white-space: pre;margin:0.33rem 0;position: relative;z-index:9999999999;'> <pre style='-webkit-overflow-scrolling: touch;background-color: #f5f5f5;color: #4a4a4a;font-size: 12px;line-height:18px;overflow-x: auto;padding: 0.5rem 1.5rem;word-wrap: normal;white-space: pre;margin:0.33rem 0;position: relative;z-index:9999999999;'>
<div style='color:#9f9f9f;font-size:10px;' title='{$this->trace['file']}'>[ file: {$this->trace['file']}:{$this->trace['line']} ]</div> <div style='color:#9f9f9f;font-size:10px;' title='{$this->trace['file']}'>[ file: {$this->trace['file']}:{$this->trace['line']} ] <small>timestamp: {$this->trace['time']}</small></div>
$data $data
</pre> </pre>
HTML; HTML;
@ -51,7 +52,7 @@ HTML;
$this->trace['file'] ??= "?"; $this->trace['file'] ??= "?";
$this->trace['line'] ??= "?"; $this->trace['line'] ??= "?";
$header = "File: {$this->trace['file']} | line : {$this->trace['line']}"; $header = "File: {$this->trace['file']} | line : {$this->trace['line']} | time : {$this->trace['time']}";
return str_repeat('-', strlen($header)) . PHP_EOL . $header . PHP_EOL . str_repeat('-', strlen($header)) . PHP_EOL . $data . PHP_EOL; return str_repeat('-', strlen($header)) . PHP_EOL . $header . PHP_EOL . str_repeat('-', strlen($header)) . PHP_EOL . $data . PHP_EOL;
} }