public function dumpStack(
        string $message = null,
        string $type = null,
        string $errfile = null,
        int $errline = null,
        $errcontext = null,
        array $stack = null
    ) {
        global $NABU_MESSAGE_TYPE_NAME;

        if (($errtype = nb_getArrayValueByKey($type, $NABU_MESSAGE_TYPE_NAME)) === null) {
            $this->nb_engine->errorLog("Unknow error type [$type]: $message in $errfile [line:$errline]");
        } else {
            $this->nb_engine->errorLog("$errtype: $message in $errfile [line:$errline]");
        }

        if ($stack === null) {
            $stack = debug_backtrace(true);
        }
        $count = -1;

        do {
            foreach ($stack as $line) {
                if ($count < 0 &&
                    (!array_key_exists('file', $line) ||
                        !array_key_exists('line', $line) ||
                        $line['file'] !== $errfile ||
                        $line['line'] !== $errline
                    )
                ) {
                    continue;
                } elseif (array_key_exists('file', $line) &&
                          $line['file'] === $errfile && $line['line'] === $errline
                ) {
                    $count++;
                    continue;
                }

                $source = '';

                if (array_key_exists(self::LINE_CLASS, $line)) {
                    $source .= $line[self::LINE_CLASS];
                }
                if (array_key_exists('type', $line)) {
                    $source .= $line['type'];
                }
                if (array_key_exists(self::LINE_FUNCTION, $line)) {
                    $source .= $line[self::LINE_FUNCTION];
                }
                if (array_key_exists(self::LINE_CLASS, $line) &&
                    array_key_exists('type', $line) &&
                    array_key_exists(self::LINE_FUNCTION, $line) &&
                    array_key_exists('args', $line) &&
                    is_array($line['args']) &&
                    count($line['args']) > 0 &&
                    $line[self::LINE_CLASS] == 'nabu\\core\\CNabuPluginManager' &&
                    $line[self::LINE_FUNCTION] == 'invoqueCommand'
                ) {
                    $source .= ' calling command ['.$line['args'][0].']';
                }
                if (array_key_exists('file', $line)) {
                    $source .= ' in '.$line['file'];
                }
                if (array_key_exists('line', $line)) {
                    $source .= " [line:$line[line]]";
                }

                $this->nb_engine->errorLog("#$count     at $source");

                $count++;
            }
            $count++;
        } while ($count < 1);
    }