WordPress at a glance
function is not described

PHPMailer\PHPMailer

PHPMailer::edebug() protected WP 1.0

Output debugging info via a user-defined method. Only generates output if debug output is enabled.

{} It's a method of the class: PHPMailer{}

No Hooks.

Return

null. Nothing.

Usage

// protected - for code of main (parent) or child class
$result = $this->edebug( $str );
$str(string) (required)
-

Notes

  • See: PHPMailer::$Debugoutput
  • See: PHPMailer::$SMTPDebug

Code of PHPMailer::edebug() WP 5.7.2

<?php
protected function edebug($str)
{
    if ($this->SMTPDebug <= 0) {
        return;
    }
    //Is this a PSR-3 logger?
    if ($this->Debugoutput instanceof \Psr\Log\LoggerInterface) {
        $this->Debugoutput->debug($str);

        return;
    }
    //Avoid clash with built-in function names
    if (is_callable($this->Debugoutput) && !in_array($this->Debugoutput, ['error_log', 'html', 'echo'])) {
        call_user_func($this->Debugoutput, $str, $this->SMTPDebug);

        return;
    }
    switch ($this->Debugoutput) {
        case 'error_log':
            //Don't output, just log
            /** @noinspection ForgottenDebugOutputInspection */
            error_log($str);
            break;
        case 'html':
            //Cleans up output a bit for a better looking, HTML-safe output
            echo htmlentities(
                preg_replace('/[\r\n]+/', '', $str),
                ENT_QUOTES,
                'UTF-8'
            ), "<br>\n";
            break;
        case 'echo':
        default:
            //Normalize line breaks
            $str = preg_replace('/\r\n|\r/m', "\n", $str);
            echo gmdate('Y-m-d H:i:s'),
            "\t",
                //Trim trailing space
            trim(
                //Indent for readability, except for trailing break
                str_replace(
                    "\n",
                    "\n                   \t                  ",
                    trim($str)
                )
            ),
            "\n";
    }
}