public function debug($subject = null, $body = null, $request = true, $server = true) {
        // initialize email
        $email = (new Email('debug'))
            ->setTemplate('Unimatrix/Cake.debug')
            ->setLayout('Unimatrix/Cake.debug');

        // get controller and method
        $location = [];
        foreach(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS) as $one) {
            // ignore current function
            if($one['function'] == __FUNCTION__)
                continue;

            // check if private or protected
            $check = new \ReflectionMethod($one['class'], $one['function']);
            if($check->isPrivate() || $check->isProtected()) {
                // @codeCoverageIgnoreStart
                $location[3] = $one['function'];
                continue;
                // @codeCoverageIgnoreEnd
            }

            // set class and function
            $location[1] = str_replace(['Controller', 'App\\\\', 'TestCase\\\\'], null, $one['class']);
            $location[2] = $one['function'];
            break;
        }

        // sort before using
        ksort($location);

        // overwrite locations
        if(isset($location[1])) {
            if($location[1] == 'Unimatrix\Cake\Console\EmailConsoleErrorHandler') $location = ['EmailConsoleErrorHandler'];
            elseif($location[1] == 'Unimatrix\Cake\Error\EmailErrorHandler') $location = ['EmailErrorHandler'];
            elseif($location[1] == 'Unimatrix\Cake\Error\Middleware\EmailErrorHandlerMiddleware') $location = ['EmailErrorHandlerMiddleware'];
            elseif($location[1] == 'Unimatrix\Cake\Test\Component\EmailComponentTest') $location = ['EmailComponentTest'];
        }

        // get brand
        $from = $email->getFrom();
        $brand = reset($from);

        // set subject
        $email->setSubject($brand . ' report: [' . implode('->', $location) . '] ' . $subject);
        $email->setViewVars(['subject' => $email->getSubject()]);

        // body start
        $body = $body == strip_tags($body) ? nl2br($body) : $body;

        // show request
        if($request) {
            if(isset($_POST) && !empty($_POST))
                $body .= Misc::dump($_POST, '$_POST', true);

            if(isset($_GET) && !empty($_GET))
                $body .= Misc::dump($_GET, '$_GET', true);

            if(isset($_COOKIE) && !empty($_COOKIE))
                $body .= Misc::dump($_COOKIE, '$_COOKIE', true);

            if(isset($_SESSION) && !empty($_SESSION))
                $body .= Misc::dump($_SESSION, '$_SESSION', true);
        }

        // show server
        if($server)
            $body .= Misc::dump($_SERVER, '$_SERVER', true);

        // send email
        return $email->send($body);
    }