Debugger::line

Add debug line output

@param mixed $expression
@param bool  $export
176315
public static function line($expression, $export = false)
    {
        $trace = static::whereCall(__CLASS__ . '::line()', 'debug_line()');

        if ($export === true) {
            $trace->expression = var_export($expression, true);
        } else {
            $trace->expression = var_format($expression);
        }

        static::$chronology[] = $trace;
    }
1336250
function debug($str, $TYPE = 0, $file = "", $line = 0)
    {
        if ($this->debug)
        {
            echo "<br>[$file:$line:" . ($this->getDiffTime()) . "]$str";
            flush();
            if ($TYPE == 1)
            {
                exit;
            }
        }
    }
1185279
protected function save_to_debug($string)
    {
        if ($this->debug) {
            $file = fopen($this->debug_file, 'a+');

            if (!$file) {
                $this->error = 604;
            } else {
                fwrite($file, '[' . date('Y-m-d H:i:s') . '] (' . $this->version . ') ' . $string . "\n");
                fclose($file);
            }
        }
    }
1340161
static function dump($var, $trace = true)
    {
        $d = Debug::getInstance();

        if ($d->level < 1) {
            return;
        }

        if ($d->terminal) {
            $c = $d->console;

            if (!is_array($var)) {
                $c->writeln(print_r($var, 1), 'blue');
            } else {
                $lines = explode("\n", print_r($var, 1));
                foreach ($lines as $line) {
                    preg_match_all('|(.*)\[(.*)\] \=\>(.*)|', $line, $m);
                    
                    if (!isset($m[0][0])) {
                        $c->writeln($line);
                    } else {
                        $c->write($m[1][0] . '[', 'blue');
                        $c->write($m[2][0], 'light_red');
                        $c->write('] =>', 'blue');
                        $c->writeln($m[3][0], 'blue');
                    }
                }
            }

        } else {
            $txt = preg_replace('/\[(.*)\]/u', '[<span style="color:#d00">$1</span>]', print_r($var, 1));
            echo '<pre style="color:blue">' . $txt . "</pre>";
        }

        if ($trace)
            $d->_trace();
    }
899767
public function logDebug($line, $args = self::NO_ARGUMENTS)
	{
        $this->log($line, self::DEBUG, $args);
    }
1345848
public function debug($count = 0, $config = array())
    {
        $tmp = array();
        $list = array();
        $this->init($config);
        $number = $count;
        if ($header = $this->getCore()->next()) {
            while ($data = $this->getCore()->next()) {
                if ($data == null) {
                    break;
                }
                $tmp[] = $data;
                $model = $this->build($header, $data);
                $number--;
                if ($model) {
                    if (($count == 0 || $number >= 0) && $model && $model->valid()) {
                        $list[] = $model;
                    }
                }
            }
        }
        print_debug($header, $tmp, $list);
    }
1204485
public function debug($msg, $vars = array()) {
		$this->mailMessage(self::LEVEL_DEBUG, $msg);

		if($this->checkLevel($this->loglevels, self::LEVEL_DEBUG) !== true)
			return;

		if(!is_array($vars))
			$vars = array($vars);

		$varDump = '';
		$varCount = count($vars);

		if($varCount > 0) {
			$vars = array_values($vars);
			$bt = debug_backtrace();

			$content = file($bt[0]['file']);
			$line = $content[$bt[0]['line'] - 1];

			preg_match('/debug\((.+?),array\((.+)\)\)/', $line, $matches);

			$varNames = null;
			if(count($matches) > 0)
				$varNames = explode(',', $matches[2]);

			for($i = 0; $i < $varCount; $i++) {
				$printedVar = trim(var_export($vars[$i], true));
				$varDump .= "\r\n\t" . (($varNames !== null) ? trim($varNames[$i]) . '=' : '') . str_replace("\n", "\r\n\t", $printedVar);
			}
		}

		$this->writeMessage(self::LEVEL_DEBUG, $msg . $varDump);
	}
116063
def add_debug(parser):
    """"""
    parser.add_argument(
        '-d', '--debug', action='store_const', const=logging.DEBUG, default=logging.INFO, help='Set DEBUG output')
870532
public function startDebug($listener = null, $type = "")
    {
        if (!Text::isEmpty($type) && !in_array($type, ["exec", "query"])) {
            throw new DbException("Invalid filter type. Valid filter types are 'exec' and 'query'");
        }
        
        $this->_debugListener = $listener !== null? $listener: function ($sql) {
            echo "$sql\n";
        };
        
        $types = Text::isEmpty($type)? ["exec", "query"]: [$type];
        foreach ($types as $type) {
            $this->_debugger->on($type, $this->_debugListener);
        }
    }
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);
    }
602181
final public function setDebug($callback = true)
    {
        if ($callback === true) {
            if (php_sapi_name() === 'cli') {
                $callback = new DebuggerOutConsole();
            } else {
                $callback = new DebuggerOutHtml();
            }
        }
        $this->debugCallback = $callback;
    }
814711
public function debugVariableText($val)
    {
        // Check debug
        if (is_object($val) && ClassInfo::hasMethod($val, 'debug')) {
            return $val->debug();
        }

        // Format as array
        if (is_array($val)) {
            $result = '';
            foreach ($val as $key => $valItem) {
                $valText = $this->debugVariableText($valItem);
                $result .= "$key = $valText\n";
            }
            return $result;
        }

        // Format object
        if (is_object($val)) {
            return print_r($val, true);
        }

        // Format bool
        if (is_bool($val)) {
            return '(bool) ' . ($val ? 'true' : 'false');
        }

        // Format text
        if (is_string($val)) {
            return wordwrap($val, self::config()->columns);
        }

        // Other
        return var_export($val, true);
    }
1160057
public static function debug($msg, $mode = null, $offset = null)
    {
        switch (Config::get('debug')) {
        case 'THEDEBUG':
            if (class_exists('Xiphe\THEMASTER\THEDEBUG')) {
                Xiphe\THEMASTER\debug($msg, $mode, null, 2+$offset);
            }
            break;
        case 'Exception':
            throw new \Exception($msg, 1);
            break;
        default:
            break;
        }
    }
325709
public static function vd($var, bool $dump = true, bool $stop = true, int $obLevel = 0): void
    {
        if ($stop) {
            while (ob_get_level() > $obLevel) {
                ob_end_clean();
            }
        }
        
        ob_start();
        if (empty($_SERVER['DOCUMENT_ROOT'])) {
            $dump ? var_dump($var) : print_r($var);
            echo PHP_EOL . str_replace("=>\n", '  =>', ob_get_clean());
        } else {
            echo '<pre>';
            $dump ? var_dump($var) : print_r($var);
            echo htmlspecialchars(str_replace("=>\n", '  =>', ob_get_clean()));
            echo '</pre>';
        }
        
        if ($stop) {
            throw new DebugStopExecutionException();
        }
    }
306762
public function set($variable, $value = '', $export = false)
    {
        $line = $this->composeLine($variable, $value, $export);
        $number = $this->has($variable) ? $this->line_numbers[$variable] : null;
        $this->writeLine($line, $number);
        $this->load();

        return $line;
    }
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();
    }
952281
public function export(bool $export, bool $client = true)
    {
        return $this->options([
            'exportenabled'  => $export,
            'exportatclient' => $client,
        ]);
    }