Return formatted debug output.

@param string $r Rendered material

@return string SQL syntax of query
512546
public function getDebugQuery($r = null)
    {
        if ($r === null) {
            $r = $this->_render();
        }

        $d = $r;
        $pp = array();
        $d = preg_replace('/`([^`]*)`/', '`<font color="black">\1</font>`', $d);
        foreach (array_reverse($this->params) as $key => $val) {
            if (is_string($val)) {
                $d = preg_replace('/'.$key.'([^_]|$)/', '"<font color="green">'.
                    htmlspecialchars(addslashes($val)).'</font>"\1', $d);
            } elseif (is_null($val)) {
                $d = preg_replace(
                    '/'.$key.'([^_]|$)/',
                    '<font color="black">NULL</font>\1',
                    $d
                );
            } elseif (is_numeric($val)) {
                $d = preg_replace(
                    '/'.$key.'([^_]|$)/',
                    '<font color="red">'.$val.'</font>\1',
                    $d
                );
            } else {
                $d = preg_replace('/'.$key.'([^_]|$)/', $val.'\1', $d);
            }

            $pp[] = $key;
        }

        return $d." <font color='gray'>[".
            implode(', ', $pp).']</font>';
    }
1358744
protected function query_row ( $sql )
    {
        $sql = $this->sql_printf(func_get_args());
        if (!($res = pg_query($this->conn, $sql)))
        {
            $this->sql_errcheck($sql);
        }
        if ($row = pg_fetch_array($res))
        {
            $rs = $row;
        }
        else
        {
            $rs = false;
        }
        pg_free_result($res);
        return $rs;
    }
1140449
public static function display_debug($obj)
    {
        // prepare information of assigned variables
        $ptr = self::get_debug_vars($obj);
        if ($obj instanceof Smarty) {
            $smarty = clone $obj;
        } else {
            $smarty = clone $obj->smarty;
        }
        $_assigned_vars = $ptr->tpl_vars;
        ksort($_assigned_vars);
        $_config_vars = $ptr->config_vars;
        ksort($_config_vars);
        $smarty->registered_filters = array();
        $smarty->autoload_filters = array();
        $smarty->default_modifiers = array();
        $smarty->force_compile = false;
        $smarty->left_delimiter = '{';
        $smarty->right_delimiter = '}';
        $smarty->debugging = false;
        $smarty->force_compile = false;
        $_template = new Smarty_Internal_Template($smarty->debug_tpl, $smarty);
        $_template->caching = false;
        $_template->disableSecurity();
        $_template->cache_id = null;
        $_template->compile_id = null;
        if ($obj instanceof Smarty_Internal_Template) {
            $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
        }
        if ($obj instanceof Smarty) {
            $_template->assign('template_data', self::$template_data);
        } else {
            $_template->assign('template_data', null);
        }
        $_template->assign('assigned_vars', $_assigned_vars);
        $_template->assign('config_vars', $_config_vars);
        $_template->assign('execution_time', microtime(true) - $smarty->start_time);
        echo $_template->fetch();
    }
498587
public function debug()
    {
        $print = "Lazer::table(" . $this->name . ")\n";
        foreach ($this->pending as $function => $values)
        {
            if (!empty($values))
            {

                if (is_array($values))
                {
                    if (is_array(reset($values)))
                    {
                        foreach ($values as $value)
                        {
                            if ($function == 'where')
                            {
                                array_shift($value);
                            }
                            if ($function == 'with')
                            {
                                $params = implode(':', $value);
                            }
                            else
                            {
                                $params = implode(', ', $value);
                            }
                            $print .= "\t" . '->' . $function . '(' . $params . ')' . "\n";
                        }
                    }
                    else
                    {
                        $params = implode(', ', $values);
                        $print .= "\t" . '->' . $function . '(' . $params . ')' . "\n";
                    }
                }
                else
                {
                    $print .= "\t" . '->' . $function . '(' . $values . ')' . "\n";
                }
            }
        }
        echo '<pre>' . print_r($print, true) . '</pre>';
        $this->clearQuery();
    }
1013252
public static function display_debugging_messages($return = false) {
        if (empty(self::$debuggings)) {
            return false;
        }

        $debugstring = '';
        foreach(self::$debuggings as $debug) {
            $debugstring .= 'Debugging: ' . $debug->message . "\n" . trim($debug->from) . "\n";
        }

        if ($return) {
            return $debugstring;
        }
        echo $debugstring;
        return true;
    }
615335
public function dump() : string
    {
        $html  = '<p><i>You have made ' . self::$numQueries . ' database queries.</i></p><pre>';
        
        foreach (self::$queries as $key => $val) {
            $params = empty(self::$params[$key])
                ? null
                : htmlentities(print_r(self::$params[$key], 1), null, 'UTF-8') . '<br/><br/>';
            $html .= htmlentities($val, null, 'UTF-8') . '<br/><br/>' . $params;
        }
        
        return $html . '</pre>';
    }
243256
public function output($type = 'array')
    {
        $debug = Arrays\RemoveElement::first($this->debug, 2);
        $debug = array_merge([(array) $this->current()], $debug);

        if( is_numeric($type) )
        {
            return (object) ( $debug[$type] ?? $this->_default() );
        }
        elseif( $type === 'array' )
        {
            return $debug;
        }
        elseif( $type === 'string' )
        {
            return output($debug, [], true);
        }
        else
        {
            return $this->_default();
        }
    }
739312
public function debugDumpParams()
    {
        $str  = "SQL: [".strlen($this->_statement)."] ".$this->_statement."\n";
        $str .= "Params: ".sizeof($this->_binds)."\n";
        foreach ($this->_binds as $key => $value) {
            $str .= "Key: Name: [".strlen($key)."] $key\n";
            $str .= "name=[".strlen($key)."] \"$key\"\n";
            $str .= "is_param=1\n";
        }
        echo substr($str, 0, strlen($str)-1);
    }
258443
public function debug(?string $name = null)
    {
        return $name !== null ? $this->query[$name] : $this->query;
    }
142489
public function col_db($row) : string {
        $output = '';

        $output .= \html_writer::div(get_string('task_stats:dbreads', 'admin', $row->dbreads));
        $output .= \html_writer::div(get_string('task_stats:dbwrites', 'admin', $row->dbwrites));

        return $output;
    }
156037
private function debug($str)
        {
            $this->log($str);
            if ($this->debug == true) {
                if (PHP_SAPI != 'cli') {
                    $str = '<br/><pre>' . htmlspecialchars($str) . '</pre>';
                }
                echo "\n" . $str;
            }
        }
918426
public function output_html($data, $query='') {
        global $OUTPUT;

        $context = (object) [
            'expressions' => [],
            'name' => $this->get_full_name()
        ];

        if (empty($data)) {
            $looplimit = 1;
        } else {
            $looplimit = (count($data)/2)+1;
        }

        for ($i=0; $i<$looplimit; $i++) {

            $expressionname = 'expression'.$i;

            if (!empty($data[$expressionname])){
                $expression = $data[$expressionname];
            } else {
                $expression = '';
            }

            $valuename = 'value'.$i;

            if (!empty($data[$valuename])){
                $value = $data[$valuename];
            } else {
                $value= '';
            }

            $context->expressions[] = [
                'index' => $i,
                'expression' => $expression,
                'value' => $value
            ];
        }

        $element = $OUTPUT->render_from_template('core_admin/setting_devicedetectregex', $context);

        return format_admin_setting($this, $this->visiblename, $element, $this->description, false, '', null, $query);
    }
720300
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);
    }
324546
public function debug()
    {
        $query = $this->pdo->prepare(<<<SQL
SELECT *
FROM robotstxt__cache1
WHERE base = :base;
SQL
        );
        $query->bindValue('base', $this->base, \PDO::PARAM_STR);
        $query->execute();
        return $query->rowCount() > 0 ? $query->fetch(\PDO::FETCH_ASSOC) : [];
    }
433784
protected function parseRPCResult($res)
    {
        $rpcRes = $res['data'];

        if (!empty($rpcRes['output'])) {
            echo $rpcRes['output'];
        }

        if (!empty($rpcRes['exception'])) {
            $exception = new \Exception($rpcRes['exception']['msg'], $rpcRes['exception']['code']);

            $file = new \ReflectionProperty($exception, 'file');
            $file->setAccessible(true);
            $file->setValue($exception, $rpcRes['exception']['file']);

            $line = new \ReflectionProperty($exception, 'line');
            $line->setAccessible(true);
            $line->setValue($exception, $rpcRes['exception']['line']);

            throw $exception;
        }

        if (isset($rpcRes['status']) && $rpcRes['status'] != 200) {
            return false;
        }

        return isset($rpcRes['return']) ? $rpcRes['return'] : null;
    }
545543
public static function pre()
    {
        $nbArgs = func_num_args();
        
        $content = '';
        for ($i = 0; $i < $nbArgs; $i++) {
            $mixed = func_get_arg($i);
            
            $content .= print_r($mixed, 1);
        }
        
        if (php_sapi_name() == 'cli') {
            $output = $content;
        }
        else {
            $output = '<pre class="debug">' . $content . '</pre>';
        }
        
        return $output;
    }
1016148
public function debug() {
        echo "filePath    = " . $this->filePath . PHP_EOL;
        echo "startMarker = " . $this->startMarker . PHP_EOL;
        echo "endMarker   = " . $this->endMarker . PHP_EOL;
        echo "startIndex  = " . $this->startIndex . PHP_EOL;
        echo "endIndex    = " . $this->endIndex . PHP_EOL;
        echo "numLines    = " . $this->numLines . PHP_EOL;
        echo "Start       = " . print_r($this->beforeLines, true);
        echo "Auto      = " . print_r($this->autoLines, true);
        echo "End         = " . print_r($this->afterLines, true);
        return $this;
    }