1.0.0 Alpha Release #59

Merged
netkas merged 213 commits from v1.0.0_alpha into master 2023-01-29 23:27:58 +00:00
Showing only changes of commit 5beb06abda - Show all commits

View file

@ -18,6 +18,11 @@
*/ */
private static $largestTickLength = 0; private static $largestTickLength = 0;
/**
* @var float|int
*/
private static $lastTickTime;
/** /**
* Inline Progress bar, created by dealnews.com. * Inline Progress bar, created by dealnews.com.
* *
@ -118,13 +123,35 @@
}; };
$tick_time = (string)microtime(true); $tick_time = (string)microtime(true);
if(strlen($tick_time) > self::$largestTickLength) if(strlen($tick_time) > self::$largestTickLength)
{
self::$largestTickLength = strlen($tick_time); self::$largestTickLength = strlen($tick_time);
}
if(strlen($tick_time) < self::$largestTickLength) if(strlen($tick_time) < self::$largestTickLength)
{
/** @noinspection PhpRedundantOptionalArgumentInspection */ /** @noinspection PhpRedundantOptionalArgumentInspection */
$tick_time = str_pad($tick_time, (strlen($tick_time) + (self::$largestTickLength - strlen($tick_time))), ' ', STR_PAD_RIGHT); $tick_time = str_pad($tick_time, (strlen($tick_time) + (self::$largestTickLength - strlen($tick_time))), ' ', STR_PAD_RIGHT);
}
return '[' . $tick_time . '] ' . $input; $fmt_tick = $tick_time;
if(self::$lastTickTime !== null)
{
$timeDiff = microtime(true) - self::$lastTickTime;
if ($timeDiff > 1.0)
{
$fmt_tick = Console::formatColor($tick_time, ConsoleColors::LightRed);
}
elseif ($timeDiff > 0.5)
{
$fmt_tick = Console::formatColor($tick_time, ConsoleColors::LightYellow);
}
}
self::$lastTickTime = $tick_time;
return '[' . $fmt_tick . '] ' . $input;
} }
/** /**
@ -182,6 +209,14 @@
$trace_msg .= ' > '; $trace_msg .= ' > ';
} }
/** Apply syntax highlighting using regular expressions */
// Hyperlinks
$message = preg_replace('/(https?:\/\/[^\s]+)/', Console::formatColor('$1', ConsoleColors::LightBlue), $message);
// File Paths
$message = preg_replace('/(\/[^\s]+)/', Console::formatColor('$1', ConsoleColors::LightCyan), $message);
/** @noinspection PhpUnnecessaryStringCastInspection */ /** @noinspection PhpUnnecessaryStringCastInspection */
$message = self::setPrefix(LogLevel::Debug, (string)$trace_msg . $message); $message = self::setPrefix(LogLevel::Debug, (string)$trace_msg . $message);