public static function debug(string $format)
    {
        if (!is_resource(self::$debug_stream))
            self::$debug_stream = fopen('php://output', 'w');

        $args = func_get_args();
        foreach ($args as $idx => &$arg)
        {
            if ($idx === 0)
                $arg .= PHP_SAPI === 'cli' ? "\n" : "<br>\n";

            if (!is_scalar($arg))
                $arg = static::str($arg);
        }

        array_unshift($args, self::$debug_stream);
        call_user_func_array('fprintf', $args);
    }